diff mbox

[RFC/RFT,5/7] gpio: omap: rework omap_gpio_irq_startup to handle current pin state properly

Message ID 1432305354-5968-6-git-send-email-grygorii.strashko@linaro.org
State New
Headers show

Commit Message

grygorii.strashko@linaro.org May 22, 2015, 2:35 p.m. UTC
The omap_gpio_irq_startup() can be called at time when:
- corresponding GPIO has been requested already and in this case
it has to be configured as input already. If not - return with -EINVAL
and do not try to re-configure it as it could be unsafe.
- corresponding GPIO is free: reconfigure GPIO as input.

In addition, call omap_enable_gpio_module directly as all needed
checks are already present inside it.

Signed-off-by: Grygorii Strashko <grygorii.strashko@linaro.org>
 drivers/gpio/gpio-omap.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff mbox


diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 2fbd569..1c226f1 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -790,11 +790,23 @@  static unsigned int omap_gpio_irq_startup(struct irq_data *d)
 	spin_lock_irqsave(&bank->lock, flags);
-	omap_gpio_init_irq(bank, offset);
+	if (!LINE_USED(bank->mod_usage, offset))
+		omap_set_gpio_direction(bank, offset, 1);
+	else if (!omap_gpio_is_input(bank, offset))
+		goto err;
+	omap_enable_gpio_module(bank, offset);
+	bank->irq_usage |= BIT(offset);
 	spin_unlock_irqrestore(&bank->lock, flags);
 	return 0;
+	spin_unlock_irqrestore(&bank->lock, flags);
+	if (!BANK_USED(bank))
+		pm_runtime_put(bank->dev);
+	return -EINVAL;
 static void omap_gpio_irq_shutdown(struct irq_data *d)