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

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

From: Andy Shevchenko <hidden>
Date: 2026-06-29 15:23:30
Also in: dri-devel, linux-arm-kernel, linux-bluetooth, linux-gpio, linux-i2c, linux-iio, linux-mmc, linux-pm, linux-usb, lkml

On Mon, Jun 29, 2026 at 03:56:29PM +0200, Arnd Bergmann wrote:
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.
Oh, that's nice!

...
+/**
+ * gpiod_name() - get a name to print for a gpio descriptor
+ * @desc: gpio or NULL pointer to query
+ *
+ * Returns:
+ * The desc->name field or a dummy string for unknown GPIOs.
+ */
+const char *gpiod_name(const struct gpio_desc *desc)
+{
+	return desc ? desc->name : "(no gpio)";
Can we get into here with wrong (error pointer descriptor)? Shouldn't you call
one of validate_desc() / VALIDATE_DESC()?

Also not sure if "(no gpio)" is a good choice. "not requested"? "not provided"?
+}
...
+static inline const char *gpiod_name(const struct gpio_desc *desc)
+{
+	WARN_ON(desc);
+	return "(no gpio)";
Hmm... This will be a second copy with a slight potential of going apart from
the other case. Perhaps a #define? (Yes, yes, I understand that there are pros
and cons, in particular readability with define is questionable.)
+}
-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help