Message ID | 1437125570-28623-2-git-send-email-mpa@pengutronix.de |
---|---|
State | New |
Headers | show |
On Fri, Jul 17, 2015 at 11:32:42AM +0200, Markus Pargmann wrote: > The name is set optionally from DT. Therefore we need to reset the name > variable for every loop iteration. Otherwise we could use a wrong or > uninitialized name. This doesn't make sense. of_get_gpio_hog falls back to using the node name so name will always be updated (unless there's an error). Could be better documented, though. > Signed-off-by: Markus Pargmann <mpa@pengutronix.de> > --- > drivers/gpio/gpiolib-of.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c > index 9a0ec48a4737..60aebe4d7c26 100644 > --- a/drivers/gpio/gpiolib-of.c > +++ b/drivers/gpio/gpiolib-of.c > @@ -209,11 +209,11 @@ static void of_gpiochip_scan_hogs(struct gpio_chip *chip) > { > struct gpio_desc *desc = NULL; > struct device_node *np; > - const char *name; > enum gpio_lookup_flags lflags; > enum gpiod_flags dflags; > > for_each_child_of_node(chip->of_node, np) { > + const char *name = NULL; > if (!of_property_read_bool(np, "gpio-hog")) > continue; Johan -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jul 28, 2015 at 11:03:31AM +0200, Johan Hovold wrote: > On Fri, Jul 17, 2015 at 11:32:42AM +0200, Markus Pargmann wrote: > > The name is set optionally from DT. Therefore we need to reset the name > > variable for every loop iteration. Otherwise we could use a wrong or > > uninitialized name. > > This doesn't make sense. of_get_gpio_hog falls back to using the node > name so name will always be updated (unless there's an error). > > Could be better documented, though. Thanks, just got the two lines wrong. Yes the name is always set correctly. Will fix it. Best regards, Markus > > > Signed-off-by: Markus Pargmann <mpa@pengutronix.de> > > --- > > drivers/gpio/gpiolib-of.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c > > index 9a0ec48a4737..60aebe4d7c26 100644 > > --- a/drivers/gpio/gpiolib-of.c > > +++ b/drivers/gpio/gpiolib-of.c > > @@ -209,11 +209,11 @@ static void of_gpiochip_scan_hogs(struct gpio_chip *chip) > > { > > struct gpio_desc *desc = NULL; > > struct device_node *np; > > - const char *name; > > enum gpio_lookup_flags lflags; > > enum gpiod_flags dflags; > > > > for_each_child_of_node(chip->of_node, np) { > > + const char *name = NULL; > > if (!of_property_read_bool(np, "gpio-hog")) > > continue; > > Johan > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 9a0ec48a4737..60aebe4d7c26 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -209,11 +209,11 @@ static void of_gpiochip_scan_hogs(struct gpio_chip *chip) { struct gpio_desc *desc = NULL; struct device_node *np; - const char *name; enum gpio_lookup_flags lflags; enum gpiod_flags dflags; for_each_child_of_node(chip->of_node, np) { + const char *name = NULL; if (!of_property_read_bool(np, "gpio-hog")) continue;
The name is set optionally from DT. Therefore we need to reset the name variable for every loop iteration. Otherwise we could use a wrong or uninitialized name. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> --- drivers/gpio/gpiolib-of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)