[PATCH 02/10] gpiolib: simplify for loop break condition
Marco Felsch
m.felsch at pengutronix.de
Fri Jun 2 00:49:13 PDT 2023
No functional change just a simplification to align it with the Linux
kernel. Also add the kernel comment to make the reason clear.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
drivers/gpio/gpiolib.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b4a3a4e550..0df43c9f8f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -529,7 +529,15 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)
of_property_read_string_array(chip->dev->of_node,
"gpio-line-names", arr, count);
- for (i = 0; i < chip->ngpio && i < count; i++)
+ /*
+ * Since property 'gpio-line-names' cannot contains gaps, we
+ * have to be sure we only assign those pins that really exists
+ * since chip->ngpio can be less.
+ */
+ if (count > chip->ngpio)
+ count = chip->ngpio;
+
+ for (i = 0; i < count; i++)
gpio_desc[chip->base + i].name = xstrdup(arr[i]);
free(arr);
--
2.39.2
More information about the barebox
mailing list