diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-16 20:15:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-16 20:15:57 -0400 |
commit | 386aa05192eb2b0e8c2efb31b7dc958550217d40 (patch) | |
tree | 17b48cedd613b4c5a2707e6d3cd90890224be353 | |
parent | 34ec4de42be5006abdd8d0c08b306ffaa64d0d5d (diff) | |
parent | 0204df470d6db830f0f2f5654ec582be84d81588 (diff) |
Merge tag 'gpio-v3.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull gpio fixes from Linus Walleij:
"Three GPIO fixes for the v3.12 series:
- A fix to the Lynxpoint IRQ handler
- Two late fixes to fallout from the gpiod refactoring"
* tag 'gpio-v3.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpiolib: let gpiod_request() return -EPROBE_DEFER
gpiolib: safer implementation of desc_to_gpio()
gpio/lynxpoint: check if the interrupt is enabled in IRQ handler
-rw-r--r-- | drivers/gpio/gpio-lynxpoint.c | 5 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 2d9ca6055e5e..41b5913ddabe 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c | |||
@@ -248,14 +248,15 @@ static void lp_gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); | 248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); |
249 | struct irq_chip *chip = irq_data_get_irq_chip(data); | 249 | struct irq_chip *chip = irq_data_get_irq_chip(data); |
250 | u32 base, pin, mask; | 250 | u32 base, pin, mask; |
251 | unsigned long reg, pending; | 251 | unsigned long reg, ena, pending; |
252 | unsigned virq; | 252 | unsigned virq; |
253 | 253 | ||
254 | /* check from GPIO controller which pin triggered the interrupt */ | 254 | /* check from GPIO controller which pin triggered the interrupt */ |
255 | for (base = 0; base < lg->chip.ngpio; base += 32) { | 255 | for (base = 0; base < lg->chip.ngpio; base += 32) { |
256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); | 256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); |
257 | ena = lp_gpio_reg(&lg->chip, base, LP_INT_ENABLE); | ||
257 | 258 | ||
258 | while ((pending = inl(reg))) { | 259 | while ((pending = (inl(reg) & inl(ena)))) { |
259 | pin = __ffs(pending); | 260 | pin = __ffs(pending); |
260 | mask = BIT(pin); | 261 | mask = BIT(pin); |
261 | /* Clear before handling so we don't lose an edge */ | 262 | /* Clear before handling so we don't lose an edge */ |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 86ef3461ec06..0dee0e0c247a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio) | |||
136 | */ | 136 | */ |
137 | static int desc_to_gpio(const struct gpio_desc *desc) | 137 | static int desc_to_gpio(const struct gpio_desc *desc) |
138 | { | 138 | { |
139 | return desc->chip->base + gpio_chip_hwgpio(desc); | 139 | return desc - &gpio_desc[0]; |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
@@ -1398,7 +1398,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1398 | int status = -EPROBE_DEFER; | 1398 | int status = -EPROBE_DEFER; |
1399 | unsigned long flags; | 1399 | unsigned long flags; |
1400 | 1400 | ||
1401 | if (!desc || !desc->chip) { | 1401 | if (!desc) { |
1402 | pr_warn("%s: invalid GPIO\n", __func__); | 1402 | pr_warn("%s: invalid GPIO\n", __func__); |
1403 | return -EINVAL; | 1403 | return -EINVAL; |
1404 | } | 1404 | } |
@@ -1406,6 +1406,8 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1406 | spin_lock_irqsave(&gpio_lock, flags); | 1406 | spin_lock_irqsave(&gpio_lock, flags); |
1407 | 1407 | ||
1408 | chip = desc->chip; | 1408 | chip = desc->chip; |
1409 | if (chip == NULL) | ||
1410 | goto done; | ||
1409 | 1411 | ||
1410 | if (!try_module_get(chip->owner)) | 1412 | if (!try_module_get(chip->owner)) |
1411 | goto done; | 1413 | goto done; |