Skip to content

Commit

Permalink
Merge tag 'gpio-v3.12-3' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Linus Torvalds committed Oct 17, 2013
2 parents 34ec4de + 0204df4 commit 386aa05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions drivers/gpio/gpio-lynxpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,15 @@ static void lp_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
struct lp_gpio *lg = irq_data_get_irq_handler_data(data);
struct irq_chip *chip = irq_data_get_irq_chip(data);
u32 base, pin, mask;
unsigned long reg, pending;
unsigned long reg, ena, pending;
unsigned virq;

/* check from GPIO controller which pin triggered the interrupt */
for (base = 0; base < lg->chip.ngpio; base += 32) {
reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT);
ena = lp_gpio_reg(&lg->chip, base, LP_INT_ENABLE);

while ((pending = inl(reg))) {
while ((pending = (inl(reg) & inl(ena)))) {
pin = __ffs(pending);
mask = BIT(pin);
/* Clear before handling so we don't lose an edge */
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio)
*/
static int desc_to_gpio(const struct gpio_desc *desc)
{
return desc->chip->base + gpio_chip_hwgpio(desc);
return desc - &gpio_desc[0];
}


Expand Down Expand Up @@ -1398,14 +1398,16 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
int status = -EPROBE_DEFER;
unsigned long flags;

if (!desc || !desc->chip) {
if (!desc) {
pr_warn("%s: invalid GPIO\n", __func__);
return -EINVAL;
}

spin_lock_irqsave(&gpio_lock, flags);

chip = desc->chip;
if (chip == NULL)
goto done;

if (!try_module_get(chip->owner))
goto done;
Expand Down

0 comments on commit 386aa05

Please sign in to comment.