[PATCH] gpio-nct5104d: switch to dynamic gpio allocation

James Buren braewoods+mgh at braewoods.net
Fri Oct 16 03:35:14 PDT 2026


The kernel complains about this module using a static GPIO base address
when it is inserted, calling it a deprecated feature. This commit switches
the GPIO base address to -1 for all instances of struct gpio_chip, which
is what enables dynamically allocated GPIO base addresses, the feature
intended to replace the static allocation that was previously used.

Furthermore, each GPIO bank was also given a new label that allows a
specific bank to be referenced via a unique label since the static base
address is no longer usable to identify a specific bank. This brings this
module into line with how the new GPIO subsystem exposes GPIO providers to
userspace and the rest of the kernel.

Consequently, this means that existing userspace software will break if
they were using this module. The GPIO of this module can still be accessed
via the ioctl APIs for gpiochip devices, and also the libgpiod userspace
library and tools that were written for this new GPIO API.

The legacy sysfs GPIO interface is still usable, as long as you look up the
new dynamic GPIO base address that is exposed in this module's sysfs entries.
All this can be found under /sys/class/gpio. You just need to look up the
gpiochip you are using by its label, extract its base address, add your line
number offset to it, and you can export it like was previously done.

Signed-off-by: James Buren <braewoods+mgh at braewoods.net>
---
 package/kernel/gpio-nct5104d/Makefile            |  2 +-
 package/kernel/gpio-nct5104d/src/gpio-nct5104d.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/package/kernel/gpio-nct5104d/Makefile b/package/kernel/gpio-nct5104d/Makefile
index 9181a2bc5f..9059018f32 100644
--- a/package/kernel/gpio-nct5104d/Makefile
+++ b/package/kernel/gpio-nct5104d/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=gpio-nct5104d
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_MAINTAINER:=Florian Eckert <Eckert.Florian at googlemail.com>
 PKG_LICENSE:=GPL-2.0
diff --git a/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c b/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c
index 6dce1c2960..196ae95973 100644
--- a/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c
+++ b/package/kernel/gpio-nct5104d/src/gpio-nct5104d.c
@@ -129,16 +129,16 @@ static int nct5104d_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 #else
 static void nct5104d_gpio_set(struct gpio_chip *chip, unsigned offset, int value);
 #endif
-#define NCT5104D_GPIO_BANK(_base, _ngpio, _regbase)			\
+#define NCT5104D_GPIO_BANK(_ngpio, _regbase, _label)			\
 	{								\
 		.chip = {						\
-			.label            = DRVNAME,			\
+			.label            = _label,			\
 			.owner            = THIS_MODULE,		\
 			.direction_input  = nct5104d_gpio_direction_in,	\
 			.get              = nct5104d_gpio_get,		\
 			.direction_output = nct5104d_gpio_direction_out,	\
 			.set              = nct5104d_gpio_set,		\
-			.base             = _base,			\
+			.base             = -1,				\
 			.ngpio            = _ngpio,			\
 			.can_sleep        = true,			\
 		},							\
@@ -149,8 +149,8 @@ static void nct5104d_gpio_set(struct gpio_chip *chip, unsigned offset, int value
 #define gpio_data(base) (base + 1)
 
 static struct nct5104d_gpio_bank nct5104d_gpio_bank[] = {
-	NCT5104D_GPIO_BANK(0 , 8, 0xE0),
-	NCT5104D_GPIO_BANK(10, 8, 0xE4)
+	NCT5104D_GPIO_BANK(8, 0xE0, DRVNAME "-0"),
+	NCT5104D_GPIO_BANK(8, 0xE4, DRVNAME "-1")
 };
 
 static int nct5104d_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
-- 
2.43.0




More information about the openwrt-devel mailing list