[PATCH] gpio: Skip over NULL and (empty string) line names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux