Skip to content

Commit 0a45c1a

Browse files
a3fBartosz Golaszewski
authored andcommitted
gpio: mxc: configure dynamic GPIO base for CONFIG_GPIO_SYSFS=n
i.MX GPIO numbering has been deterministic since commit 7e6086d ("gpio/mxc: specify gpio base for device tree probe"), a year after device tree support was first added back in 2011. Reverting to dynamically allocated GPIO base now would break most systems making use of the sysfs API. These systems will be eventually broken by the removal of the sysfs API, but that would result in GPIO scripts not working instead of essentially toggling at random according to probe order, which would happen if we unconditionally set base to -1. Yet, the warning is annoying and has resulted in many rejected attempts to remove it over the years[1][2][3]. As the i.MX GPIO driver is device tree only, GPIO_SYSFS is the only consumer of the deterministic GPIO numbering. Let's therefore restrict the static base and the warning that comes with it to configurations with CONFIG_GPIO_SYSFS enabled. [1]: https://lore.kernel.org/all/[email protected]/ [2]: https://lore.kernel.org/all/[email protected]/ [3]: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Ahmad Fatoum <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/20250507-b4-imx-gpio-base-warning-v2-1-d43d09e2c6bf@pengutronix.de Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 1275c70 commit 0a45c1a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/gpio/gpio-mxc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,14 @@ static int mxc_gpio_probe(struct platform_device *pdev)
490490
port->gc.request = mxc_gpio_request;
491491
port->gc.free = mxc_gpio_free;
492492
port->gc.to_irq = mxc_gpio_to_irq;
493-
port->gc.base = of_alias_get_id(np, "gpio") * 32;
493+
/*
494+
* Driver is DT-only, so a fixed base needs only be maintained for legacy
495+
* userspace with sysfs interface.
496+
*/
497+
if (IS_ENABLED(CONFIG_GPIO_SYSFS))
498+
port->gc.base = of_alias_get_id(np, "gpio") * 32;
499+
else /* silence boot time warning */
500+
port->gc.base = -1;
494501

495502
err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
496503
if (err)

0 commit comments

Comments
 (0)