[PATCH v2] gpio: s5p: increment bank base address only if bank is initialized
    Kaustabh Chakraborty 
    kauschluss at disroot.org
       
    Tue Oct 21 16:21:35 CEST 2025
    
    
  
There is a condition guard which ensures that the GPIO node, indeed
describes a GPIO controller.
	if (!fdtdec_get_bool(blob, node, "gpio-controller"))
		continue;
Since the bank base is being incremented in the loop, it is done so
irrespective of whether the node is a GPIO controller or not. This leads
to the incorrect resolution of bank base addresses.
Move it out of the loop, and instead increment the bank base address
only if the driver successfully binds a GPIO controller.
Reviewed-by: Henrik Grimler <henrik at grimler.se>
Fixes: b8809e60cdb5 ("dm: exynos: gpio: Convert to driver model")
Signed-off-by: Kaustabh Chakraborty <kauschluss at disroot.org>
---
Changes in v2:
- collect Reviewed-by: tags
- add Fixes: tag (Henrik Grimler)
- Link to v1: https://lore.kernel.org/r/20251017-gpio-s5p-bank-fix-v1-1-41050462cea5@disroot.org
---
 drivers/gpio/s5p_gpio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 53dbbe97b5a02d09fbf0124268faaffa31b1315f..c072f146514c63cdc98e907983a904f05cd118e7 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -319,7 +319,7 @@ static int gpio_exynos_bind(struct udevice *parent)
 	base = dev_read_addr_ptr(parent);
 	for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base;
 	     node > 0;
-	     node = fdt_next_subnode(blob, node), bank++) {
+	     node = fdt_next_subnode(blob, node)) {
 		struct exynos_gpio_plat *plat;
 		struct udevice *dev;
 		fdt_addr_t reg;
@@ -341,9 +341,8 @@ static int gpio_exynos_bind(struct udevice *parent)
 		if (reg != FDT_ADDR_T_NONE)
 			bank = (struct s5p_gpio_bank *)((ulong)base + reg);
 
-		plat->bank = bank;
-
 		debug("dev at %p: %s\n", bank, plat->bank_name);
+		plat->bank = bank++;
 	}
 
 	return 0;
---
base-commit: 582a04763aa80738c1c8ac60c47d1a5159a42833
change-id: 20251014-gpio-s5p-bank-fix-1d008cb2a1a9
Best regards,
-- 
Kaustabh Chakraborty <kauschluss at disroot.org>
    
    
More information about the U-Boot
mailing list