* [PATCH] gpiolib: make legacy interfaces optional
@ 2025-07-22 15:35 Arnd Bergmann
2025-07-22 16:27 ` Alexander Sverdlin
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Arnd Bergmann @ 2025-07-22 15:35 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: Arnd Bergmann, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Andy Shevchenko, Alexander Sverdlin,
Uwe Kleine-König, linux-gpio, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The traditional interfaces are only used on a small number of ancient
boards. Make these optional now so they can be disabled by default.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
This is the first patch of a series to turn off the legacy interfaces
by default. If we can still have this one in linux-6.17, we can more
easily merge the other patches for 6.18.
See for the longer series:
https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=config-gpio-legacy
I'm sure there are still problems in the other patches, but it
does pass my randconfig build tests on the three architectures
I'm testing on. I plan to post them after some more testing
once -rc1 is out.
drivers/gpio/Kconfig | 3 +++
drivers/gpio/Makefile | 2 +-
include/linux/gpio.h | 10 ++++++----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 12bdf6e965f1..8bda3c9d47b4 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -14,6 +14,9 @@ menuconfig GPIOLIB
if GPIOLIB
+config GPIOLIB_LEGACY
+ def_bool y
+
config GPIOLIB_FASTPATH_LIMIT
int "Maximum number of GPIOs for fast path"
range 32 512
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 88dedd298256..b01ff2b68bf6 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
obj-$(CONFIG_GPIOLIB) += gpiolib.o
obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o
-obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
+obj-$(CONFIG_GPIOLIB_LEGACY) += gpiolib-legacy.o
obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
obj-$(CONFIG_GPIO_CDEV) += gpiolib-cdev.o
obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index ff99ed76fdc3..8f85ddb26429 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -13,6 +13,11 @@
#define __LINUX_GPIO_H
#include <linux/types.h>
+#ifdef CONFIG_GPIOLIB
+#include <linux/gpio/consumer.h>
+#endif
+
+#ifdef CONFIG_GPIOLIB_LEGACY
struct device;
@@ -22,9 +27,6 @@ struct device;
#define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1))
#ifdef CONFIG_GPIOLIB
-
-#include <linux/gpio/consumer.h>
-
/*
* "valid" GPIO numbers are nonnegative and may be passed to
* setup routines like gpio_request(). Only some valid numbers
@@ -170,5 +172,5 @@ static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
}
#endif /* ! CONFIG_GPIOLIB */
-
+#endif /* CONFIG_GPIOLIB_LEGACY */
#endif /* __LINUX_GPIO_H */
--
2.39.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-22 15:35 [PATCH] gpiolib: make legacy interfaces optional Arnd Bergmann
@ 2025-07-22 16:27 ` Alexander Sverdlin
2025-07-23 8:39 ` Bartosz Golaszewski
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Alexander Sverdlin @ 2025-07-22 16:27 UTC (permalink / raw)
To: Arnd Bergmann, Linus Walleij, Bartosz Golaszewski
Cc: Arnd Bergmann, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Andy Shevchenko, Uwe Kleine-König,
linux-gpio, linux-kernel
On Tue, 2025-07-22 at 17:35 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The traditional interfaces are only used on a small number of ancient
> boards. Make these optional now so they can be disabled by default.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> This is the first patch of a series to turn off the legacy interfaces
> by default. If we can still have this one in linux-6.17, we can more
> easily merge the other patches for 6.18.
>
> See for the longer series:
> https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=config-gpio-legacy
>
> I'm sure there are still problems in the other patches, but it
> does pass my randconfig build tests on the three architectures
> I'm testing on. I plan to post them after some more testing
> once -rc1 is out.
>
> drivers/gpio/Kconfig | 3 +++
> drivers/gpio/Makefile | 2 +-
> include/linux/gpio.h | 10 ++++++----
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 12bdf6e965f1..8bda3c9d47b4 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -14,6 +14,9 @@ menuconfig GPIOLIB
>
> if GPIOLIB
>
> +config GPIOLIB_LEGACY
> + def_bool y
> +
> config GPIOLIB_FASTPATH_LIMIT
> int "Maximum number of GPIOs for fast path"
> range 32 512
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 88dedd298256..b01ff2b68bf6 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -5,7 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
>
> obj-$(CONFIG_GPIOLIB) += gpiolib.o
> obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o
> -obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
> +obj-$(CONFIG_GPIOLIB_LEGACY) += gpiolib-legacy.o
> obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
> obj-$(CONFIG_GPIO_CDEV) += gpiolib-cdev.o
> obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index ff99ed76fdc3..8f85ddb26429 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -13,6 +13,11 @@
> #define __LINUX_GPIO_H
>
> #include <linux/types.h>
> +#ifdef CONFIG_GPIOLIB
> +#include <linux/gpio/consumer.h>
> +#endif
> +
> +#ifdef CONFIG_GPIOLIB_LEGACY
>
> struct device;
>
> @@ -22,9 +27,6 @@ struct device;
> #define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1))
>
> #ifdef CONFIG_GPIOLIB
> -
> -#include <linux/gpio/consumer.h>
> -
> /*
> * "valid" GPIO numbers are nonnegative and may be passed to
> * setup routines like gpio_request(). Only some valid numbers
> @@ -170,5 +172,5 @@ static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
> }
>
> #endif /* ! CONFIG_GPIOLIB */
> -
> +#endif /* CONFIG_GPIOLIB_LEGACY */
> #endif /* __LINUX_GPIO_H */
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-22 15:35 [PATCH] gpiolib: make legacy interfaces optional Arnd Bergmann
2025-07-22 16:27 ` Alexander Sverdlin
@ 2025-07-23 8:39 ` Bartosz Golaszewski
2025-07-23 14:17 ` Andy Shevchenko
2025-07-24 14:22 ` Arnd Bergmann
2025-07-23 14:15 ` Andy Shevchenko
2025-07-24 14:25 ` (subset) " Bartosz Golaszewski
3 siblings, 2 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-07-23 8:39 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linus Walleij, Arnd Bergmann, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Andy Shevchenko, Alexander Sverdlin,
Uwe Kleine-König, linux-gpio, linux-kernel
On Tue, Jul 22, 2025 at 5:36 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> The traditional interfaces are only used on a small number of ancient
> boards. Make these optional now so they can be disabled by default.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> This is the first patch of a series to turn off the legacy interfaces
> by default. If we can still have this one in linux-6.17, we can more
> easily merge the other patches for 6.18.
>
> See for the longer series:
> https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=config-gpio-legacy
>
> I'm sure there are still problems in the other patches, but it
> does pass my randconfig build tests on the three architectures
> I'm testing on. I plan to post them after some more testing
> once -rc1 is out.
>
> drivers/gpio/Kconfig | 3 +++
> drivers/gpio/Makefile | 2 +-
> include/linux/gpio.h | 10 ++++++----
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 12bdf6e965f1..8bda3c9d47b4 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -14,6 +14,9 @@ menuconfig GPIOLIB
>
> if GPIOLIB
>
> +config GPIOLIB_LEGACY
> + def_bool y
> +
> config GPIOLIB_FASTPATH_LIMIT
> int "Maximum number of GPIOs for fast path"
> range 32 512
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 88dedd298256..b01ff2b68bf6 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -5,7 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
>
> obj-$(CONFIG_GPIOLIB) += gpiolib.o
> obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o
> -obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
> +obj-$(CONFIG_GPIOLIB_LEGACY) += gpiolib-legacy.o
> obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
> obj-$(CONFIG_GPIO_CDEV) += gpiolib-cdev.o
> obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
> diff --git a/include/linux/gpio.h b/include/linux/gpio.h
> index ff99ed76fdc3..8f85ddb26429 100644
> --- a/include/linux/gpio.h
> +++ b/include/linux/gpio.h
> @@ -13,6 +13,11 @@
> #define __LINUX_GPIO_H
>
> #include <linux/types.h>
> +#ifdef CONFIG_GPIOLIB
> +#include <linux/gpio/consumer.h>
I want to queue this ASAP but do we really need this guard here?
consumer.h already guards against !CONFIG_GPIOLIB internally, right?
Bart
> +#endif
> +
> +#ifdef CONFIG_GPIOLIB_LEGACY
>
> struct device;
>
> @@ -22,9 +27,6 @@ struct device;
> #define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1))
>
> #ifdef CONFIG_GPIOLIB
> -
> -#include <linux/gpio/consumer.h>
> -
> /*
> * "valid" GPIO numbers are nonnegative and may be passed to
> * setup routines like gpio_request(). Only some valid numbers
> @@ -170,5 +172,5 @@ static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
> }
>
> #endif /* ! CONFIG_GPIOLIB */
> -
> +#endif /* CONFIG_GPIOLIB_LEGACY */
> #endif /* __LINUX_GPIO_H */
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-22 15:35 [PATCH] gpiolib: make legacy interfaces optional Arnd Bergmann
2025-07-22 16:27 ` Alexander Sverdlin
2025-07-23 8:39 ` Bartosz Golaszewski
@ 2025-07-23 14:15 ` Andy Shevchenko
2025-07-24 14:25 ` (subset) " Bartosz Golaszewski
3 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2025-07-23 14:15 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linus Walleij, Bartosz Golaszewski, Arnd Bergmann, Peng Fan,
Lee Jones, Koichiro Den, Geert Uytterhoeven, Alexander Sverdlin,
Uwe Kleine-König, linux-gpio, linux-kernel
On Tue, Jul 22, 2025 at 05:35:43PM +0200, Arnd Bergmann wrote:
>
> The traditional interfaces are only used on a small number of ancient
> boards. Make these optional now so they can be disabled by default.
...
> +#ifdef CONFIG_GPIOLIB
> +#include <linux/gpio/consumer.h>
> +#endif
> #ifdef CONFIG_GPIOLIB
> -
> -#include <linux/gpio/consumer.h>
> -
Why is the above needed to be changed?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-23 8:39 ` Bartosz Golaszewski
@ 2025-07-23 14:17 ` Andy Shevchenko
2025-07-24 14:36 ` Arnd Bergmann
2025-07-24 14:22 ` Arnd Bergmann
1 sibling, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2025-07-23 14:17 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Arnd Bergmann, Linus Walleij, Arnd Bergmann, Peng Fan, Lee Jones,
Koichiro Den, Geert Uytterhoeven, Alexander Sverdlin,
Uwe Kleine-König, linux-gpio, linux-kernel
On Wed, Jul 23, 2025 at 10:39:32AM +0200, Bartosz Golaszewski wrote:
> On Tue, Jul 22, 2025 at 5:36 PM Arnd Bergmann <arnd@kernel.org> wrote:
...
> > +#ifdef CONFIG_GPIOLIB
> > +#include <linux/gpio/consumer.h>
>
> I want to queue this ASAP but do we really need this guard here?
> consumer.h already guards against !CONFIG_GPIOLIB internally, right?
I probably missed something, but I do not understand why we need this include
at all in the gpio.h.
> > +#endif
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-23 8:39 ` Bartosz Golaszewski
2025-07-23 14:17 ` Andy Shevchenko
@ 2025-07-24 14:22 ` Arnd Bergmann
2025-07-24 14:24 ` Bartosz Golaszewski
1 sibling, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2025-07-24 14:22 UTC (permalink / raw)
To: Bartosz Golaszewski, Arnd Bergmann
Cc: Linus Walleij, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Andy Shevchenko, Alexander Sverdlin,
Uwe Kleine-König, open list:GPIO SUBSYSTEM, linux-kernel
On Wed, Jul 23, 2025, at 10:39, Bartosz Golaszewski wrote:
> On Tue, Jul 22, 2025 at 5:36 PM Arnd Bergmann <arnd@kernel.org> wrote:
>> #include <linux/types.h>
>> +#ifdef CONFIG_GPIOLIB
>> +#include <linux/gpio/consumer.h>
>
> I want to queue this ASAP but do we really need this guard here?
> consumer.h already guards against !CONFIG_GPIOLIB internally, right?
I was trying to not change the behavior here. linux/gpio/consumer.h has
an #ifdef check but has the #else portion with empty stubs that can
be used by any driver that includes it, while drivers that include
linux/gpio.h never saw the stub version.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-24 14:22 ` Arnd Bergmann
@ 2025-07-24 14:24 ` Bartosz Golaszewski
0 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 14:24 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Linus Walleij, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Andy Shevchenko, Alexander Sverdlin,
Uwe Kleine-König, open list:GPIO SUBSYSTEM, linux-kernel
On Thu, Jul 24, 2025 at 4:22 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Wed, Jul 23, 2025, at 10:39, Bartosz Golaszewski wrote:
> > On Tue, Jul 22, 2025 at 5:36 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> >> #include <linux/types.h>
> >> +#ifdef CONFIG_GPIOLIB
> >> +#include <linux/gpio/consumer.h>
> >
> > I want to queue this ASAP but do we really need this guard here?
> > consumer.h already guards against !CONFIG_GPIOLIB internally, right?
>
> I was trying to not change the behavior here. linux/gpio/consumer.h has
> an #ifdef check but has the #else portion with empty stubs that can
> be used by any driver that includes it, while drivers that include
> linux/gpio.h never saw the stub version.
>
> Arnd
Ok, fair enough, let me queue this and we can change it later if needed.
Bart
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (subset) [PATCH] gpiolib: make legacy interfaces optional
2025-07-22 15:35 [PATCH] gpiolib: make legacy interfaces optional Arnd Bergmann
` (2 preceding siblings ...)
2025-07-23 14:15 ` Andy Shevchenko
@ 2025-07-24 14:25 ` Bartosz Golaszewski
3 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 14:25 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Arnd Bergmann
Cc: Bartosz Golaszewski, Arnd Bergmann, Peng Fan, Lee Jones,
Koichiro Den, Geert Uytterhoeven, Andy Shevchenko,
Alexander Sverdlin, Uwe Kleine-König, linux-gpio,
linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 22 Jul 2025 17:35:43 +0200, Arnd Bergmann wrote:
> The traditional interfaces are only used on a small number of ancient
> boards. Make these optional now so they can be disabled by default.
>
>
Applied, thanks!
[1/1] gpiolib: make legacy interfaces optional
https://git.kernel.org/brgl/linux/c/678bae2eaa812662929a83b3de399645e9de93ad
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpiolib: make legacy interfaces optional
2025-07-23 14:17 ` Andy Shevchenko
@ 2025-07-24 14:36 ` Arnd Bergmann
0 siblings, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2025-07-24 14:36 UTC (permalink / raw)
To: Andy Shevchenko, Bartosz Golaszewski
Cc: Arnd Bergmann, Linus Walleij, Peng Fan, Lee Jones, Koichiro Den,
Geert Uytterhoeven, Alexander Sverdlin, Uwe Kleine-König,
open list:GPIO SUBSYSTEM, linux-kernel
On Wed, Jul 23, 2025, at 16:17, Andy Shevchenko wrote:
> On Wed, Jul 23, 2025 at 10:39:32AM +0200, Bartosz Golaszewski wrote:
>> On Tue, Jul 22, 2025 at 5:36 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> ...
>
>> > +#ifdef CONFIG_GPIOLIB
>> > +#include <linux/gpio/consumer.h>
>>
>> I want to queue this ASAP but do we really need this guard here?
>> consumer.h already guards against !CONFIG_GPIOLIB internally, right?
>
> I probably missed something, but I do not understand why we need this include
> at all in the gpio.h.
We've been thinning out linux/gpio.h over the years on both the contents
and the inclusions, but I'm fairly sure that out of the 173 files that
still include it, the majority actually need the consumer interfaces.
One thing I've considered doing here was to make this file only contain
two lines
#include <linux/gpio/consumer.h>
#include <linux/gpio/legacy.h>
then then replace all of the remaining users with one or the other
in order to remove linux/gpio.h completely.
I think both approaches are useful and can be combined, but the
CONFIG_GPIOLIB_LEGACY patch seems sufficient for now.
If you want to experiment with the other one, you could try
my whole series and drop the #include <linux/gpio/consumer.h>
line to find all the instances in allmodconfig builds that should
use that in place of linux/gpio.h.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-07-24 14:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 15:35 [PATCH] gpiolib: make legacy interfaces optional Arnd Bergmann
2025-07-22 16:27 ` Alexander Sverdlin
2025-07-23 8:39 ` Bartosz Golaszewski
2025-07-23 14:17 ` Andy Shevchenko
2025-07-24 14:36 ` Arnd Bergmann
2025-07-24 14:22 ` Arnd Bergmann
2025-07-24 14:24 ` Bartosz Golaszewski
2025-07-23 14:15 ` Andy Shevchenko
2025-07-24 14:25 ` (subset) " Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).