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-fixes-for-v6.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

- fix resource handling in gpio-tegra186

- fix wakeup source leaks in gpio-mpc8xxx and gpio-zynq

- fix minor issues with some GPIO OF quirks

- deprecate GPIOD_FLAGS_BIT_NONEXCLUSIVE and devm_gpiod_unhinge()
symbols and add a TODO task to track replacing them with a better
solution

* tag 'gpio-fixes-for-v6.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
gpiolib: of: Move Atmel HSMCI quirk up out of the regulator comment
gpiolib: of: Fix the choice for Ingenic NAND quirk
gpio: zynq: Fix wakeup source leaks on device unbind
gpio: mpc8xxx: Fix wakeup source leaks on device unbind
gpio: TODO: track the removal of regulator-related workarounds
MAINTAINERS: add more keywords for the GPIO subsystem entry
gpio: deprecate devm_gpiod_unhinge()
gpio: deprecate the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag
gpio: tegra186: fix resource handling in ACPI probe path

+64 -17
+2
MAINTAINERS
··· 10151 10151 F: include/linux/gpio/ 10152 10152 F: include/linux/of_gpio.h 10153 10153 K: (devm_)?gpio_(request|free|direction|get|set) 10154 + K: GPIOD_FLAGS_BIT_NONEXCLUSIVE 10155 + K: devm_gpiod_unhinge 10154 10156 10155 10157 GPIO UAPI 10156 10158 M: Bartosz Golaszewski <brgl@bgdev.pl>
+34
drivers/gpio/TODO
··· 186 186 187 187 Encourage users to switch to using them and eventually remove the existing 188 188 global export/unexport attribues. 189 + 190 + ------------------------------------------------------------------------------- 191 + 192 + Remove GPIOD_FLAGS_BIT_NONEXCLUSIVE 193 + 194 + GPIOs in the linux kernel are meant to be an exclusive resource. This means 195 + that the GPIO descriptors (the software representation of the hardware concept) 196 + are not reference counted and - in general - only one user at a time can 197 + request a GPIO line and control its settings. The consumer API is designed 198 + around full control of the line's state as evidenced by the fact that, for 199 + instance, gpiod_set_value() does indeed drive the line as requested, instead 200 + of bumping an enable counter of some sort. 201 + 202 + A problematic use-case for GPIOs is when two consumers want to use the same 203 + descriptor independently. An example of such a user is the regulator subsystem 204 + which may instantiate several struct regulator_dev instances containing 205 + a struct device but using the same enable GPIO line. 206 + 207 + A workaround was introduced in the form of the GPIOD_FLAGS_BIT_NONEXCLUSIVE 208 + flag but its implementation is problematic: it does not provide any 209 + synchronization of usage nor did it introduce any enable count meaning the 210 + non-exclusive users of the same descriptor will in fact "fight" for the 211 + control over it. This flag should be removed and replaced with a better 212 + solution, possibly based on the new power sequencing subsystem. 213 + 214 + ------------------------------------------------------------------------------- 215 + 216 + Remove devm_gpiod_unhinge() 217 + 218 + devm_gpiod_unhinge() is provided as a way to transfer the ownership of managed 219 + enable GPIOs to the regulator core. Rather than doing that however, we should 220 + make it possible for the regulator subsystem to deal with GPIO resources the 221 + lifetime of which it doesn't control as logically, a GPIO obtained by a caller 222 + should also be freed by it.
+3 -1
drivers/gpio/gpio-mpc8xxx.c
··· 410 410 goto err; 411 411 } 412 412 413 - device_init_wakeup(dev, true); 413 + ret = devm_device_init_wakeup(dev); 414 + if (ret) 415 + return dev_err_probe(dev, ret, "Failed to init wakeup\n"); 414 416 415 417 return 0; 416 418 err:
+13 -12
drivers/gpio/gpio-tegra186.c
··· 823 823 struct gpio_irq_chip *irq; 824 824 struct tegra_gpio *gpio; 825 825 struct device_node *np; 826 + struct resource *res; 826 827 char **names; 827 828 int err; 828 829 ··· 843 842 gpio->num_banks++; 844 843 845 844 /* get register apertures */ 846 - gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security"); 847 - if (IS_ERR(gpio->secure)) { 848 - gpio->secure = devm_platform_ioremap_resource(pdev, 0); 849 - if (IS_ERR(gpio->secure)) 850 - return PTR_ERR(gpio->secure); 851 - } 845 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "security"); 846 + if (!res) 847 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 848 + gpio->secure = devm_ioremap_resource(&pdev->dev, res); 849 + if (IS_ERR(gpio->secure)) 850 + return PTR_ERR(gpio->secure); 852 851 853 - gpio->base = devm_platform_ioremap_resource_byname(pdev, "gpio"); 854 - if (IS_ERR(gpio->base)) { 855 - gpio->base = devm_platform_ioremap_resource(pdev, 1); 856 - if (IS_ERR(gpio->base)) 857 - return PTR_ERR(gpio->base); 858 - } 852 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpio"); 853 + if (!res) 854 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 855 + gpio->base = devm_ioremap_resource(&pdev->dev, res); 856 + if (IS_ERR(gpio->base)) 857 + return PTR_ERR(gpio->base); 859 858 860 859 err = platform_irq_count(pdev); 861 860 if (err < 0)
+1
drivers/gpio/gpio-zynq.c
··· 1011 1011 ret = pm_runtime_get_sync(&pdev->dev); 1012 1012 if (ret < 0) 1013 1013 dev_warn(&pdev->dev, "pm_runtime_get_sync() Failed\n"); 1014 + device_init_wakeup(&pdev->dev, 0); 1014 1015 gpiochip_remove(&gpio->chip); 1015 1016 device_set_wakeup_capable(&pdev->dev, 0); 1016 1017 pm_runtime_disable(&pdev->dev);
+5 -1
drivers/gpio/gpiolib-devres.c
··· 317 317 * @dev: GPIO consumer 318 318 * @desc: GPIO descriptor to remove resource management from 319 319 * 320 + * *DEPRECATED* 321 + * This function should not be used. It's been provided as a workaround for 322 + * resource ownership issues in the regulator framework and should be replaced 323 + * with a better solution. 324 + * 320 325 * Remove resource management from a GPIO descriptor. This is needed when 321 326 * you want to hand over lifecycle management of a descriptor to another 322 327 * mechanism. 323 328 */ 324 - 325 329 void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc) 326 330 { 327 331 int ret;
+5 -3
drivers/gpio/gpiolib-of.c
··· 193 193 */ 194 194 { "himax,hx8357", "gpios-reset", false }, 195 195 { "himax,hx8369", "gpios-reset", false }, 196 + #endif 197 + #if IS_ENABLED(CONFIG_MTD_NAND_JZ4780) 196 198 /* 197 199 * The rb-gpios semantics was undocumented and qi,lb60 (along with 198 200 * the ingenic driver) got it wrong. The active state encodes the ··· 268 266 { "fsl,imx8qm-fec", "phy-reset-gpios", "phy-reset-active-high" }, 269 267 { "fsl,s32v234-fec", "phy-reset-gpios", "phy-reset-active-high" }, 270 268 #endif 269 + #if IS_ENABLED(CONFIG_MMC_ATMELMCI) 270 + { "atmel,hsmci", "cd-gpios", "cd-inverted" }, 271 + #endif 271 272 #if IS_ENABLED(CONFIG_PCI_IMX6) 272 273 { "fsl,imx6q-pcie", "reset-gpio", "reset-gpio-active-high" }, 273 274 { "fsl,imx6sx-pcie", "reset-gpio", "reset-gpio-active-high" }, ··· 296 291 #if IS_ENABLED(CONFIG_REGULATOR_GPIO) 297 292 { "regulator-gpio", "enable-gpio", "enable-active-high" }, 298 293 { "regulator-gpio", "enable-gpios", "enable-active-high" }, 299 - #endif 300 - #if IS_ENABLED(CONFIG_MMC_ATMELMCI) 301 - { "atmel,hsmci", "cd-gpios", "cd-inverted" }, 302 294 #endif 303 295 }; 304 296 unsigned int i;
+1
include/linux/gpio/consumer.h
··· 31 31 #define GPIOD_FLAGS_BIT_DIR_OUT BIT(1) 32 32 #define GPIOD_FLAGS_BIT_DIR_VAL BIT(2) 33 33 #define GPIOD_FLAGS_BIT_OPEN_DRAIN BIT(3) 34 + /* GPIOD_FLAGS_BIT_NONEXCLUSIVE is DEPRECATED, don't use in new code. */ 34 35 #define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4) 35 36 36 37 /**