Skip to content

Commit

Permalink
Merge tag 'gpio-fixes-for-v5.7-rc6' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/brgl/linux into fixes

gpio fixes for v5.7-rc6

- fix probing for chips without PWM in gpio-mvebu
- fix ida_simple_get() error path in gpio-exar
- fix user-space notifications for line state changes
  • Loading branch information
Linus Walleij committed May 18, 2020
2 parents b9bbe6e + 9fefca7 commit e75dfba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
7 changes: 5 additions & 2 deletions drivers/gpio/gpio-exar.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
mutex_init(&exar_gpio->lock);

index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
if (index < 0)
goto err_destroy;
if (index < 0) {
ret = index;
goto err_mutex_destroy;
}

sprintf(exar_gpio->name, "exar_gpio%d", index);
exar_gpio->gpio_chip.label = exar_gpio->name;
Expand All @@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev)

err_destroy:
ida_simple_remove(&ida_index, index);
err_mutex_destroy:
mutex_destroy(&exar_gpio->lock);
return ret;
}
Expand Down
15 changes: 9 additions & 6 deletions drivers/gpio/gpio-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,15 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
"marvell,armada-370-gpio"))
return 0;

/*
* There are only two sets of PWM configuration registers for
* all the GPIO lines on those SoCs which this driver reserves
* for the first two GPIO chips. So if the resource is missing
* we can't treat it as an error.
*/
if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
return 0;

if (IS_ERR(mvchip->clk))
return PTR_ERR(mvchip->clk);

Expand All @@ -804,12 +813,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
mvchip->mvpwm = mvpwm;
mvpwm->mvchip = mvchip;

/*
* There are only two sets of PWM configuration registers for
* all the GPIO lines on those SoCs which this driver reserves
* for the first two GPIO chips. So if the resource is missing
* we can't treat it as an error.
*/
mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm");
if (IS_ERR(mvpwm->membase))
return PTR_ERR(mvpwm->membase);
Expand Down
15 changes: 13 additions & 2 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
if (ret)
goto out_free_descs;
}

atomic_notifier_call_chain(&desc->gdev->notifier,
GPIOLINE_CHANGED_REQUESTED, desc);

dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
offset);
}
Expand Down Expand Up @@ -1083,6 +1087,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
if (ret)
goto out_free_desc;

atomic_notifier_call_chain(&desc->gdev->notifier,
GPIOLINE_CHANGED_REQUESTED, desc);

le->irq = gpiod_to_irq(desc);
if (le->irq <= 0) {
ret = -ENODEV;
Expand Down Expand Up @@ -2998,8 +3005,6 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
}
done:
spin_unlock_irqrestore(&gpio_lock, flags);
atomic_notifier_call_chain(&desc->gdev->notifier,
GPIOLINE_CHANGED_REQUESTED, desc);
return ret;
}

Expand Down Expand Up @@ -4961,6 +4966,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
return ERR_PTR(ret);
}

atomic_notifier_call_chain(&desc->gdev->notifier,
GPIOLINE_CHANGED_REQUESTED, desc);

return desc;
}
EXPORT_SYMBOL_GPL(gpiod_get_index);
Expand Down Expand Up @@ -5026,6 +5034,9 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
return ERR_PTR(ret);
}

atomic_notifier_call_chain(&desc->gdev->notifier,
GPIOLINE_CHANGED_REQUESTED, desc);

return desc;
}
EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
Expand Down

0 comments on commit e75dfba

Please sign in to comment.