aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier.martinez@collabora.co.uk>2013-10-15 20:47:30 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-10-16 04:06:00 -0400
commit2f56e0a57ff1bbf973bec86e527f222de8c4b4f9 (patch)
tree763ed6b762c629fd15cca4a9d592e68d2e6aef93 /drivers/gpio
parent263c43a4479ecce52c0fdc84b4620e146263d549 (diff)
gpio/omap: use gpiolib API to mark a GPIO used as an IRQ
The OMAP GPIO driver keeps track about GPIO pins that are used as IRQ lines for two reasons: 1) To prevent GPIO banks to be disabled while one of their GPIO pins are only used as an interrupt line. 2) To not allow another caller to set the GPIO pin as output. Now gpiolib has an API to mark GPIO pins as used as IRQ lines so the GPIO core only allows to set as output GPIO pins not tied to an IRQ. So there is no need to have custom code for 2). The IRQ usage still has to be maintained locally for 1) though. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-omap.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 89675f862308..f319c9ffd4a8 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -514,6 +514,14 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
514 return -EINVAL; 514 return -EINVAL;
515 } 515 }
516 516
517 retval = gpio_lock_as_irq(&bank->chip, offset);
518 if (retval) {
519 dev_err(bank->dev, "unable to lock offset %d for IRQ\n",
520 offset);
521 spin_unlock_irqrestore(&bank->lock, flags);
522 return retval;
523 }
524
517 bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio); 525 bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio);
518 spin_unlock_irqrestore(&bank->lock, flags); 526 spin_unlock_irqrestore(&bank->lock, flags);
519 527
@@ -797,6 +805,7 @@ static void gpio_irq_shutdown(struct irq_data *d)
797 unsigned offset = GPIO_INDEX(bank, gpio); 805 unsigned offset = GPIO_INDEX(bank, gpio);
798 806
799 spin_lock_irqsave(&bank->lock, flags); 807 spin_lock_irqsave(&bank->lock, flags);
808 gpio_unlock_as_irq(&bank->chip, offset);
800 bank->irq_usage &= ~(1 << offset); 809 bank->irq_usage &= ~(1 << offset);
801 _disable_gpio_module(bank, offset); 810 _disable_gpio_module(bank, offset);
802 _reset_gpio(bank, gpio); 811 _reset_gpio(bank, gpio);
@@ -957,22 +966,13 @@ static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
957{ 966{
958 struct gpio_bank *bank; 967 struct gpio_bank *bank;
959 unsigned long flags; 968 unsigned long flags;
960 int retval = 0;
961 969
962 bank = container_of(chip, struct gpio_bank, chip); 970 bank = container_of(chip, struct gpio_bank, chip);
963 spin_lock_irqsave(&bank->lock, flags); 971 spin_lock_irqsave(&bank->lock, flags);
964
965 if (LINE_USED(bank->irq_usage, offset)) {
966 retval = -EINVAL;
967 goto exit;
968 }
969
970 bank->set_dataout(bank, offset, value); 972 bank->set_dataout(bank, offset, value);
971 _set_gpio_direction(bank, offset, 0); 973 _set_gpio_direction(bank, offset, 0);
972
973exit:
974 spin_unlock_irqrestore(&bank->lock, flags); 974 spin_unlock_irqrestore(&bank->lock, flags);
975 return retval; 975 return 0;
976} 976}
977 977
978static int gpio_debounce(struct gpio_chip *chip, unsigned offset, 978static int gpio_debounce(struct gpio_chip *chip, unsigned offset,