Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gpio-v5.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
"Here are some (very) late fixes for GPIO, none of them very serious
except the one tagged for stable for enabling IRQ on open drain lines:

- Fix probing of mvebu chips without PWM

- Fix error path on ida_get_simple() on the exar driver

- Notify userspace properly about line status changes when flags are
changed on lines.

- Fix a sleeping while holding spinlock in the mellanox driver.

- Fix return value of the PXA and Kona probe calls.

- Fix IRQ locking of open drain lines, it is fine to have IRQs on
open drain lines flagged for output"

* tag 'gpio-v5.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: fix locking open drain IRQ lines
gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe()
gpio: pxa: Fix return value of pxa_gpio_probe()
gpio: mlxbf2: Fix sleeping while holding spinlock
gpiolib: notify user-space about line status changes after flags are set
gpio: exar: Fix bad handling for ida_simple_get error path
gpio: mvebu: Fix probing for chips without PWM

+42 -18
+1 -1
drivers/gpio/gpio-bcm-kona.c
··· 625 625 626 626 kona_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0); 627 627 if (IS_ERR(kona_gpio->reg_base)) { 628 - ret = -ENXIO; 628 + ret = PTR_ERR(kona_gpio->reg_base); 629 629 goto err_irq_domain; 630 630 } 631 631
+5 -2
drivers/gpio/gpio-exar.c
··· 148 148 mutex_init(&exar_gpio->lock); 149 149 150 150 index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); 151 - if (index < 0) 152 - goto err_destroy; 151 + if (index < 0) { 152 + ret = index; 153 + goto err_mutex_destroy; 154 + } 153 155 154 156 sprintf(exar_gpio->name, "exar_gpio%d", index); 155 157 exar_gpio->gpio_chip.label = exar_gpio->name; ··· 178 176 179 177 err_destroy: 180 178 ida_simple_remove(&ida_index, index); 179 + err_mutex_destroy: 181 180 mutex_destroy(&exar_gpio->lock); 182 181 return ret; 183 182 }
+3 -3
drivers/gpio/gpio-mlxbf2.c
··· 127 127 { 128 128 u32 arm_gpio_lock_val; 129 129 130 - spin_lock(&gs->gc.bgpio_lock); 131 130 mutex_lock(yu_arm_gpio_lock_param.lock); 131 + spin_lock(&gs->gc.bgpio_lock); 132 132 133 133 arm_gpio_lock_val = readl(yu_arm_gpio_lock_param.io); 134 134 ··· 136 136 * When lock active bit[31] is set, ModeX is write enabled 137 137 */ 138 138 if (YU_LOCK_ACTIVE_BIT(arm_gpio_lock_val)) { 139 - mutex_unlock(yu_arm_gpio_lock_param.lock); 140 139 spin_unlock(&gs->gc.bgpio_lock); 140 + mutex_unlock(yu_arm_gpio_lock_param.lock); 141 141 return -EINVAL; 142 142 } 143 143 ··· 152 152 static void mlxbf2_gpio_lock_release(struct mlxbf2_gpio_context *gs) 153 153 { 154 154 writel(YU_ARM_GPIO_LOCK_RELEASE, yu_arm_gpio_lock_param.io); 155 - mutex_unlock(yu_arm_gpio_lock_param.lock); 156 155 spin_unlock(&gs->gc.bgpio_lock); 156 + mutex_unlock(yu_arm_gpio_lock_param.lock); 157 157 } 158 158 159 159 /*
+9 -6
drivers/gpio/gpio-mvebu.c
··· 782 782 "marvell,armada-370-gpio")) 783 783 return 0; 784 784 785 + /* 786 + * There are only two sets of PWM configuration registers for 787 + * all the GPIO lines on those SoCs which this driver reserves 788 + * for the first two GPIO chips. So if the resource is missing 789 + * we can't treat it as an error. 790 + */ 791 + if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm")) 792 + return 0; 793 + 785 794 if (IS_ERR(mvchip->clk)) 786 795 return PTR_ERR(mvchip->clk); 787 796 ··· 813 804 mvchip->mvpwm = mvpwm; 814 805 mvpwm->mvchip = mvchip; 815 806 816 - /* 817 - * There are only two sets of PWM configuration registers for 818 - * all the GPIO lines on those SoCs which this driver reserves 819 - * for the first two GPIO chips. So if the resource is missing 820 - * we can't treat it as an error. 821 - */ 822 807 mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm"); 823 808 if (IS_ERR(mvpwm->membase)) 824 809 return PTR_ERR(mvpwm->membase);
+2 -2
drivers/gpio/gpio-pxa.c
··· 660 660 pchip->irq1 = irq1; 661 661 662 662 gpio_reg_base = devm_platform_ioremap_resource(pdev, 0); 663 - if (!gpio_reg_base) 664 - return -EINVAL; 663 + if (IS_ERR(gpio_reg_base)) 664 + return PTR_ERR(gpio_reg_base); 665 665 666 666 clk = clk_get(&pdev->dev, NULL); 667 667 if (IS_ERR(clk)) {
+22 -4
drivers/gpio/gpiolib.c
··· 729 729 if (ret) 730 730 goto out_free_descs; 731 731 } 732 + 733 + atomic_notifier_call_chain(&desc->gdev->notifier, 734 + GPIOLINE_CHANGED_REQUESTED, desc); 735 + 732 736 dev_dbg(&gdev->dev, "registered chardev handle for line %d\n", 733 737 offset); 734 738 } ··· 1086 1082 ret = gpiod_direction_input(desc); 1087 1083 if (ret) 1088 1084 goto out_free_desc; 1085 + 1086 + atomic_notifier_call_chain(&desc->gdev->notifier, 1087 + GPIOLINE_CHANGED_REQUESTED, desc); 1089 1088 1090 1089 le->irq = gpiod_to_irq(desc); 1091 1090 if (le->irq <= 0) { ··· 3005 2998 } 3006 2999 done: 3007 3000 spin_unlock_irqrestore(&gpio_lock, flags); 3008 - atomic_notifier_call_chain(&desc->gdev->notifier, 3009 - GPIOLINE_CHANGED_REQUESTED, desc); 3010 3001 return ret; 3011 3002 } 3012 3003 ··· 4220 4215 } 4221 4216 } 4222 4217 4223 - if (test_bit(FLAG_IS_OUT, &desc->flags)) { 4218 + /* To be valid for IRQ the line needs to be input or open drain */ 4219 + if (test_bit(FLAG_IS_OUT, &desc->flags) && 4220 + !test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { 4224 4221 chip_err(gc, 4225 4222 "%s: tried to flag a GPIO set as output for IRQ\n", 4226 4223 __func__); ··· 4285 4278 4286 4279 if (!IS_ERR(desc) && 4287 4280 !WARN_ON(!test_bit(FLAG_USED_AS_IRQ, &desc->flags))) { 4288 - WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags)); 4281 + /* 4282 + * We must not be output when using IRQ UNLESS we are 4283 + * open drain. 4284 + */ 4285 + WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags) && 4286 + !test_bit(FLAG_OPEN_DRAIN, &desc->flags)); 4289 4287 set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); 4290 4288 } 4291 4289 } ··· 4973 4961 return ERR_PTR(ret); 4974 4962 } 4975 4963 4964 + atomic_notifier_call_chain(&desc->gdev->notifier, 4965 + GPIOLINE_CHANGED_REQUESTED, desc); 4966 + 4976 4967 return desc; 4977 4968 } 4978 4969 EXPORT_SYMBOL_GPL(gpiod_get_index); ··· 5040 5025 gpiod_put(desc); 5041 5026 return ERR_PTR(ret); 5042 5027 } 5028 + 5029 + atomic_notifier_call_chain(&desc->gdev->notifier, 5030 + GPIOLINE_CHANGED_REQUESTED, desc); 5043 5031 5044 5032 return desc; 5045 5033 }