All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: Skip over NULL and (empty string) line names
@ 2020-12-15 12:37 Linus Walleij
  2020-12-18 16:05 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2020-12-15 12:37 UTC (permalink / raw)
  To: linux-gpio; +Cc: Bartosz Golaszewski, Linus Walleij, Guillaume Tucker

The core will warn if we try to assign the name ''
(empty string) to two lines. Actively ignore NULL
and empty string in the name assignment loop.

Reported-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpiolib.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 26c75499d549..d07da3ffd140 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -343,6 +343,10 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
 	for (i = 0; i != gc->ngpio; ++i) {
 		struct gpio_desc *gpiod;
 
+		/* Skip NULL or '(empty string)' names */
+		if (!gc->names[i] || !strlen(gc->names[i]))
+			continue;
+
 		gpiod = gpio_name_to_desc(gc->names[i]);
 		if (gpiod && (gpiod->gdev == gdev)) {
 			dev_err(&gdev->dev,
@@ -352,8 +356,12 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
 	}
 
 	/* Then add all names to the GPIO descriptors */
-	for (i = 0; i != gc->ngpio; ++i)
+	for (i = 0; i != gc->ngpio; ++i) {
+		/* Skip NULL or '(empty string)' names */
+		if (!gc->names[i] || !strlen(gc->names[i]))
+			continue;
 		gdev->descs[i].name = gc->names[i];
+	}
 
 	return 0;
 }
@@ -404,6 +412,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
 	for (i = 0; i < count; i++) {
 		struct gpio_desc *gpiod;
 
+		/* Skip NULL or '(empty string)' names */
+		if (!names[i] || !strlen(names[i]))
+			continue;
 		gpiod = gpio_name_to_desc(names[i]);
 		if (gpiod && (gpiod->gdev == gdev)) {
 			dev_err(&gdev->dev,
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-18 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 12:37 [PATCH] gpio: Skip over NULL and (empty string) line names Linus Walleij
2020-12-18 16:05 ` Andy Shevchenko
2020-12-18 16:06   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.