]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
gpio: uclass: show DT gpio-line-names
authorVincent Jardin <vjardin@free.fr>
Sun, 10 May 2026 21:28:18 +0000 (23:28 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 25 May 2026 19:43:24 +0000 (13:43 -0600)
gpio status -a does not have labels: the existing path walks
the per-bank requested label table.
Issue: The boards that populate the standard gpio-line-names
property in their device tree end up with anonymous entries,
which is not logic with the purpose of having those names in the DT.

No impact with boards that does not set gpio-line-names.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
drivers/gpio/gpio-uclass.c

index 7651d5360d688ec1a7962ca651120ca299ce3478..4d40738e5aabd36561b5c06b1f4b79842865e180 100644 (file)
@@ -877,8 +877,19 @@ static int get_function(struct udevice *dev, int offset, bool skip_unused,
                return -ENODEV;
        if (offset < 0 || offset >= uc_priv->gpio_count)
                return -EINVAL;
-       if (namep)
+       if (namep) {
                *namep = uc_priv->name[offset];
+               /* Fall back to DT "gpio-line-names" for unrequested pins. */
+               if (CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LINE_NAME) &&
+                   (!*namep || !**namep)) {
+                       const char *dt_name = NULL;
+
+                       if (!dev_read_string_index(dev, "gpio-line-names",
+                                                  offset, &dt_name) &&
+                           dt_name && *dt_name)
+                               *namep = dt_name;
+               }
+       }
        if (skip_unused && !gpio_is_claimed(uc_priv, offset))
                return GPIOF_UNUSED;
        if (ops->get_function) {