Thread (8 messages) 8 messages, 5 authors, 25d ago

Re: [PATCH] [RFC] gpiolib: introduce gpio_name() helper

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2026-06-29 15:29:42
Also in: dri-devel, linux-arm-kernel, linux-bluetooth, linux-gpio, linux-i2c, linux-iio, linux-mmc, linux-pm, linux-usb, lkml

Hi Arnd,

On Mon, 29 Jun 2026 at 15:59, Arnd Bergmann [off-list ref] wrote:
From: Arnd Bergmann <arnd@arndb.de>

Most remaining users of desc_to_gpio() only call it for printing debug
information.

Replace this with a new gpiod_name() helper that returns the
gpio_desc->name string after checking the gpio_desc pointer.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks for your patch!
Not sure if this the way we want to take this, or if the gpio name is
an appropriate replacement in debug printk.

Since most of the callers of desc_to_gpio() and gpio_to_desc() are
otherwise in drivers that already depend on CONFIG_GPIOLIB_LEGACY and
include linux/gpio/legacy.h, only a handful of instances remain that
are otherwise in files that otherwise only use the descriptor interfaces:
quoted hunk ↗ jump to hunk
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -758,8 +758,8 @@ int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc,

        fwd->descs[offset] = desc;

-       dev_dbg(chip->parent, "%u => gpio %d irq %d\n", offset,
-               desc_to_gpio(desc), gpiod_to_irq(desc));
+       dev_dbg(chip->parent, "%u => gpio %s irq %d\n", offset,
+               gpiod_name(desc), gpiod_to_irq(desc));

        return 0;
 }
Before, this printed:

    gpio-aggregator gpio-aggregator.1: 0 => gpio 589 irq 188
    gpio-aggregator gpio-aggregator.1: 1 => gpio 590 irq 189

After, this prints:

    gpio-aggregator gpio-aggregator.1: 0 => gpio (null) irq 188
    gpio-aggregator gpio-aggregator.1: 1 => gpio (null) irq 189

Same results for instantiation using sysfs or configfs[1], although
the latter does have optional support for specifying the name.

[1] Documentation/admin-guide/gpio/gpio-aggregator.rst

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help