Some GPIO fixes for the v5.7 kernel:
- Fix pin configuration in the PCA953x driver. - Ruggedize the watch/unwatch ioctl(). - Possible call to a sleeping function when holding a spinlock, avoid this. - Fix UML builds with DT overlays. - Mask Tegra GPIO IRQs during shutdown(). -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEElDRnuGcz/wPCXQWMQRCzN7AZXXMFAl66XSUACgkQQRCzN7AZ XXNltQ/7BdS2CMpulb7J+wqy3Urloz90yokzi9XlndNcTwnYRKVaRkDC2tRQ//Kx hfvskyKyL2mr/wfV7Lzs3lpTdTdwLKvS1yuXq1AdmI7fqlUixavBEpYQR4KGBMHd 7SZTMOEgW8fcj9LzJ3e0MglGKoDpdcIP7vWeV9EJY4FmNiiprjD3KjoDoAr3DBMN H+miCgTjeKHAmhMye22DcMxutFC/qzq5mzi9O5RJukZktOp4ROkYWZ6IjBCmG7g6 okuqr+aPX3uLUa4d80kdcaEm+MrIcQi9Gbq1NW82IuERGfPO81RRZkruXMU7zFRK eBV4h2EB52wgr6VjOz88Ea/+xoZBxfj/xS1oKqQTBvVX4DeFiX+nC6aeaVNMkOqR QHUysOUSjrYERI2+2xcGYoxXoA619e/XfaEJxCLpcx5hG/PgqNI2mawViaLJ7lfn bL3iMKkwvzLcwBC4NKg66wI/q9um3v1ltKRUuxHGdymUmAE8FeZdZKAoL0Exz3t4 L6s//l4vG9+7Na7mu4pYeGS9yzgN0oCYhoYPc0m1KtfwFyqOIT6qORULbsNU/dHq wosnfsiOM2sDW/KYHoggNd4ZzLNVGCuj92GKqTSbsdjzLLBRsGQyareNEGbJHPi4 MoP+Dbt96x+krjNGJiSkYLcJ4dykq5bCbuJKXcw0l5WBLY9LxdU= =U86d -----END PGP SIGNATURE----- Merge tag 'gpio-v5.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio Pull GPIO fixes from Linus Walleij: "Some GPIO fixes for v5.7, slightly overdue. Been learning MMUs and KASan that is why it's late. Bartosz helped me out, luckily! - Fix pin configuration in the PCA953x driver - Ruggedize the watch/unwatch ioctl() - Possible call to a sleeping function when holding a spinlock, avoid this - Fix UML builds with DT overlays - Mask Tegra GPIO IRQs during shutdown()" * tag 'gpio-v5.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: tegra: mask GPIO IRQs during IRQ shutdown gpio: of: Build fails if CONFIG_OF_DYNAMIC enabled without CONFIG_OF_GPIO gpiolib: don't call sleeping functions with a spinlock taken gpiolib: improve the robustness of watch/unwatch ioctl() gpio: pca953x: Fix pca953x_gpio_set_config
This commit is contained in:
commit
8ec91c0fce
@ -531,7 +531,7 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
{
|
||||
struct pca953x_chip *chip = gpiochip_get_data(gc);
|
||||
|
||||
switch (config) {
|
||||
switch (pinconf_to_config_param(config)) {
|
||||
case PIN_CONFIG_BIAS_PULL_UP:
|
||||
case PIN_CONFIG_BIAS_PULL_DOWN:
|
||||
return pca953x_gpio_set_pull_up_down(chip, offset, config);
|
||||
|
@ -368,6 +368,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d)
|
||||
struct tegra_gpio_info *tgi = bank->tgi;
|
||||
unsigned int gpio = d->hwirq;
|
||||
|
||||
tegra_gpio_irq_mask(d);
|
||||
gpiochip_unlock_as_irq(&tgi->gc, gpio);
|
||||
}
|
||||
|
||||
|
@ -1158,8 +1158,19 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
|
||||
struct gpioline_info *info)
|
||||
{
|
||||
struct gpio_chip *gc = desc->gdev->chip;
|
||||
bool ok_for_pinctrl;
|
||||
unsigned long flags;
|
||||
|
||||
/*
|
||||
* This function takes a mutex so we must check this before taking
|
||||
* the spinlock.
|
||||
*
|
||||
* FIXME: find a non-racy way to retrieve this information. Maybe a
|
||||
* lock common to both frameworks?
|
||||
*/
|
||||
ok_for_pinctrl =
|
||||
pinctrl_gpio_can_use_line(gc->base + info->line_offset);
|
||||
|
||||
spin_lock_irqsave(&gpio_lock, flags);
|
||||
|
||||
if (desc->name) {
|
||||
@ -1186,7 +1197,7 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
|
||||
test_bit(FLAG_USED_AS_IRQ, &desc->flags) ||
|
||||
test_bit(FLAG_EXPORT, &desc->flags) ||
|
||||
test_bit(FLAG_SYSFS, &desc->flags) ||
|
||||
!pinctrl_gpio_can_use_line(gc->base + info->line_offset))
|
||||
!ok_for_pinctrl)
|
||||
info->flags |= GPIOLINE_FLAG_KERNEL;
|
||||
if (test_bit(FLAG_IS_OUT, &desc->flags))
|
||||
info->flags |= GPIOLINE_FLAG_IS_OUT;
|
||||
@ -1227,6 +1238,7 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
void __user *ip = (void __user *)arg;
|
||||
struct gpio_desc *desc;
|
||||
__u32 offset;
|
||||
int hwgpio;
|
||||
|
||||
/* We fail any subsequent ioctl():s when the chip is gone */
|
||||
if (!gc)
|
||||
@ -1259,13 +1271,19 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
if (IS_ERR(desc))
|
||||
return PTR_ERR(desc);
|
||||
|
||||
hwgpio = gpio_chip_hwgpio(desc);
|
||||
|
||||
if (cmd == GPIO_GET_LINEINFO_WATCH_IOCTL &&
|
||||
test_bit(hwgpio, priv->watched_lines))
|
||||
return -EBUSY;
|
||||
|
||||
gpio_desc_to_lineinfo(desc, &lineinfo);
|
||||
|
||||
if (copy_to_user(ip, &lineinfo, sizeof(lineinfo)))
|
||||
return -EFAULT;
|
||||
|
||||
if (cmd == GPIO_GET_LINEINFO_WATCH_IOCTL)
|
||||
set_bit(gpio_chip_hwgpio(desc), priv->watched_lines);
|
||||
set_bit(hwgpio, priv->watched_lines);
|
||||
|
||||
return 0;
|
||||
} else if (cmd == GPIO_GET_LINEHANDLE_IOCTL) {
|
||||
@ -1280,7 +1298,12 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
if (IS_ERR(desc))
|
||||
return PTR_ERR(desc);
|
||||
|
||||
clear_bit(gpio_chip_hwgpio(desc), priv->watched_lines);
|
||||
hwgpio = gpio_chip_hwgpio(desc);
|
||||
|
||||
if (!test_bit(hwgpio, priv->watched_lines))
|
||||
return -EBUSY;
|
||||
|
||||
clear_bit(hwgpio, priv->watched_lines);
|
||||
return 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
@ -5289,8 +5312,9 @@ static int __init gpiolib_dev_init(void)
|
||||
gpiolib_initialized = true;
|
||||
gpiochip_setup_devs();
|
||||
|
||||
if (IS_ENABLED(CONFIG_OF_DYNAMIC))
|
||||
WARN_ON(of_reconfig_notifier_register(&gpio_of_notifier));
|
||||
#if IS_ENABLED(CONFIG_OF_DYNAMIC) && IS_ENABLED(CONFIG_OF_GPIO)
|
||||
WARN_ON(of_reconfig_notifier_register(&gpio_of_notifier));
|
||||
#endif /* CONFIG_OF_DYNAMIC && CONFIG_OF_GPIO */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user