]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: nomadik: don't print out global GPIO numbers in debugfs callbacks
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 26 Aug 2025 09:54:36 +0000 (11:54 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 3 Sep 2025 07:38:13 +0000 (09:38 +0200)
In order to further limit the number of references to the GPIO base
number stored in struct gpio_chip, replace the global GPIO numbers in
the output of debugfs callbacks by hardware offsets.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250826-gpio-dbg-show-base-v1-2-7f27cd7f2256@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-nomadik.c
drivers/pinctrl/nomadik/pinctrl-nomadik.c
include/linux/gpio/gpio-nomadik.h

index bcf4b07dd4584f884992ae35caa8aa1aaacb619e..fde4b416faa81816ee554f85e5665f16d5defa06 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/cleanup.h>
 #include <linux/clk.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -396,10 +397,10 @@ static int nmk_gpio_get_mode(struct nmk_gpio_chip *nmk_chip, int offset)
 }
 
 void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
-                          struct gpio_chip *chip, unsigned int offset,
-                          unsigned int gpio)
+                          struct gpio_chip *chip, unsigned int offset)
 {
        struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip);
+       struct gpio_desc *desc;
        int mode;
        bool is_out;
        bool data_out;
@@ -425,15 +426,15 @@ void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
        data_out = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & BIT(offset));
        mode = nmk_gpio_get_mode(nmk_chip, offset);
 #ifdef CONFIG_PINCTRL_NOMADIK
-       if (mode == NMK_GPIO_ALT_C && pctldev)
-               mode = nmk_prcm_gpiocr_get_mode(pctldev, gpio);
+       if (mode == NMK_GPIO_ALT_C && pctldev) {
+               desc = gpio_device_get_desc(chip->gpiodev, offset);
+               mode = nmk_prcm_gpiocr_get_mode(pctldev, desc_to_gpio(desc));
+       }
 #endif
 
        if (is_out) {
                seq_printf(s, " gpio-%-3d (%-20.20s) out %s           %s",
-                          gpio,
-                          label ?: "(none)",
-                          str_hi_lo(data_out),
+                          offset, label ?: "(none)", str_hi_lo(data_out),
                           (mode < 0) ? "unknown" : modes[mode]);
        } else {
                int irq = chip->to_irq(chip, offset);
@@ -445,9 +446,7 @@ void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
                };
 
                seq_printf(s, " gpio-%-3d (%-20.20s) in  %s %s",
-                          gpio,
-                          label ?: "(none)",
-                          pulls[pullidx],
+                          offset, label ?: "(none)", pulls[pullidx],
                           (mode < 0) ? "unknown" : modes[mode]);
 
                val = nmk_gpio_get_input(chip, offset);
@@ -479,10 +478,10 @@ void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
 
 static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 {
-       unsigned int i, gpio = chip->base;
+       unsigned int i;
 
-       for (i = 0; i < chip->ngpio; i++, gpio++) {
-               nmk_gpio_dbg_show_one(s, NULL, chip, i, gpio);
+       for (i = 0; i < chip->ngpio; i++) {
+               nmk_gpio_dbg_show_one(s, NULL, chip, i);
                seq_puts(s, "\n");
        }
 }
index 8940e04fcf4cc4898cda5a5734574bfed6a175c6..db0311b14132276b9020bf3331fd9bb7a4f73a59 100644 (file)
@@ -584,7 +584,7 @@ static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
                seq_printf(s, "invalid pin offset");
                return;
        }
-       nmk_gpio_dbg_show_one(s, pctldev, chip, offset - chip->base, offset);
+       nmk_gpio_dbg_show_one(s, pctldev, chip, offset - chip->base);
 }
 
 static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned int *reserved_maps,
index b5a84864650d0c228de6e7350a28449537a829d9..7ba53b499e164edf410475cf62d60f399aaaa0c7 100644 (file)
@@ -261,8 +261,7 @@ struct platform_device;
  * true.
  */
 void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
-                          struct gpio_chip *chip, unsigned int offset,
-                          unsigned int gpio);
+                          struct gpio_chip *chip, unsigned int offset);
 
 #else