Skip to contentSkip to conversation

gpio: More cleanups to legacy header

PATCH Applied Andy Shevchenko 3 participants 6 messages May 31, 2025 – Jun 10, 2025 GPIO

lore
Share & tools
lore
#0 lore raw

cover gpio: More cleanups to legacy header

If I'm not missing anything the 'struct gpio' is not used and GPIO_DYNAMIC_* constants nowadays are private to gpiolib.c. Hence this series.

Note, this seems already the case for the upcoming v6.16 cycle, hence I would like to route these patches as fixes to it to prevent any possible use of the mentioned definitions in a new code.

Andy Shevchenko (2):
gpio: Remove unused 'struct gpio' definition
gpiolib: Move GPIO_DYNAMIC_* constants to its only user

 drivers/gpio/gpiolib.c | 13 +++++++++++++
 include/linux/gpio.h   | 25 -------------------------
 2 files changed, 13 insertions(+), 25 deletions(-)
Signature · 1 line
2.47.2
#1 lore raw

PATCH 1/2 gpio: Remove unused 'struct gpio' definition

There is no user for the legacy 'struct gpio', remove it for good.

---
 include/linux/gpio.h | 12 ------------
 1 file changed, 12 deletions(-)
include/linux/gpio.h +0 -12
index c1ec62c11ed3..1893e5d4c0c9 100644
@@ -21,18 +21,6 @@ struct device;
 #define GPIOF_OUT_INIT_LOW	((0 << 0) | (0 << 1))
 #define GPIOF_OUT_INIT_HIGH	((0 << 0) | (1 << 1))
 
-/**
- * struct gpio - a structure describing a GPIO with configuration
- * @gpio:	the GPIO number
- * @flags:	GPIO configuration as specified by GPIOF_*
- * @label:	a literal description string of this GPIO
- */
-struct gpio {
-	unsigned	gpio;
-	unsigned long	flags;
-	const char	*label;
-};
-
 #ifdef CONFIG_GPIOLIB
 
 #include <linux/gpio/consumer.h>
Signature · 1 line
2.47.2
#3 lore raw

PATCH 2/2 gpiolib: Move GPIO_DYNAMIC_* constants to its only user

In reply to Andy Shevchenko

There is no need to export GPIO_DYNAMIC_* constants, especially via legacy header which is subject to remove. Move the mentioned constants to its only user, i.e. gpiolib.c.

---
 drivers/gpio/gpiolib.c | 13 +++++++++++++
 include/linux/gpio.h   | 13 -------------
 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpio/gpiolib.c +13 -0
index 839948b859e3..85296419a514 100644
@@ -74,6 +74,19 @@ static const struct bus_type gpio_bus_type = {
 	.match = gpio_bus_match,
 };
 
+/*
+ * At the end we want all GPIOs to be dynamically allocated from 0.
+ * However, some legacy drivers still perform fixed allocation.
+ * Until they are all fixed, leave 0-512 space for them.
+ */
+#define GPIO_DYNAMIC_BASE	512
+/*
+ * Define the maximum of the possible GPIO in the global numberspace.
+ * While the GPIO base and numbers are positive, we limit it with signed
+ * maximum as a lot of code is using negative values for special cases.
+ */
+#define GPIO_DYNAMIC_MAX	INT_MAX
+
 /*
  * Number of GPIOs to use for the fast path in set array
  */
include/linux/gpio.h +0 -13
index 1893e5d4c0c9..d105a207eaa2 100644
@@ -45,19 +45,6 @@ static inline bool gpio_is_valid(int number)
  * extra memory (for code and for per-GPIO table entries).
  */
 
-/*
- * At the end we want all GPIOs to be dynamically allocated from 0.
- * However, some legacy drivers still perform fixed allocation.
- * Until they are all fixed, leave 0-512 space for them.
- */
-#define GPIO_DYNAMIC_BASE	512
-/*
- * Define the maximum of the possible GPIO in the global numberspace.
- * While the GPIO base and numbers are positive, we limit it with signed
- * maximum as a lot of code is using negative values for special cases.
- */
-#define GPIO_DYNAMIC_MAX	INT_MAX
-
 /* Always use the library code for GPIO management calls,
  * or when sleeping may be involved.
  */
Signature · 1 line
2.47.2
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] gpiolib: Move GPIO_DYNAMIC_* constants to its only user

Quoted 5 lines · Andy Shevchenko

There is no need to export GPIO_DYNAMIC_* constants, especially via legacy header which is subject to remove. Move the mentioned constants to its only user, i.e. gpiolib.c.

Yours,
Linus Walleij

#5 lore raw
In reply to Andy Shevchenko

From: Bartosz Golaszewski <[email protected]>

Quoted 9 lines · Andy Shevchenko

If I'm not missing anything the 'struct gpio' is not used and GPIO_DYNAMIC_* constants nowadays are private to gpiolib.c. Hence this series.

Note, this seems already the case for the upcoming v6.16 cycle, hence I would like to route these patches as fixes to it to prevent any possible use of the mentioned definitions in a new code.

[...]

Applied, thanks!

[1/2] gpio: Remove unused 'struct gpio' definition

      https://git.kernel.org/brgl/linux/c/9b4d4c952e28f97c5e653c8b9453690f7e63cc5a
[2/2] gpiolib: Move GPIO_DYNAMIC_* constants to its only user
      https://git.kernel.org/brgl/linux/c/6595ea2761df191c2ec500d5f54b57592b969f5c

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>