diff options
author | Grygorii Strashko <grygorii.strashko@linaro.org> | 2015-05-22 17:35:52 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-06-01 16:53:54 +0200 |
commit | 121dcb760426ca67ee90a8b2db6a75eee010f8e3 (patch) | |
tree | 043416955bff282d15aafd7118a2fc89c718b4fe /drivers/gpio/gpio-omap.c | |
parent | c3518172129a60a1f3071e61a8a4ffc50c7b2a68 (diff) | |
download | op-kernel-dev-121dcb760426ca67ee90a8b2db6a75eee010f8e3.zip op-kernel-dev-121dcb760426ca67ee90a8b2db6a75eee010f8e3.tar.gz |
gpio: omap: rework omap_gpio_irq_startup to handle current pin state properly
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>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-omap.c')
-rw-r--r-- | drivers/gpio/gpio-omap.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 606b401..b0c57d5 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) pm_runtime_get_sync(bank->dev); 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); omap_gpio_unmask_irq(d); return 0; +err: + 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) |