Commit 8dc19697 authored by Christophe Blaess's avatar Christophe Blaess Committed by Linus Walleij

Accept partial 'gpio-line-names' property.

Documentation/devicetree/bindings/gpio/gpio.txt says: "The names are
assigned starting from line offset 0 from left to right from the
passed array. An incomplete array (where the number of passed named
are less than ngpios) will still be used up until the last provided
valid line index". This patch makes it actually work this way.
Signed-off-by: default avatarChristophe Blaess <christophe.blaess@logilin.fr>
Signed-off-by: default avatarPatrick Boettcher <p@yai.se>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 46748073
...@@ -29,32 +29,29 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip, ...@@ -29,32 +29,29 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip,
struct gpio_device *gdev = chip->gpiodev; struct gpio_device *gdev = chip->gpiodev;
const char **names; const char **names;
int ret, i; int ret, i;
int count;
ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", count = fwnode_property_read_string_array(fwnode, "gpio-line-names",
NULL, 0); NULL, 0);
if (ret < 0) if (count < 0)
return; return;
if (ret != gdev->ngpio) { if (count > gdev->ngpio)
dev_warn(&gdev->dev, count = gdev->ngpio;
"names %d do not match number of GPIOs %d\n", ret,
gdev->ngpio);
return;
}
names = kcalloc(gdev->ngpio, sizeof(*names), GFP_KERNEL); names = kcalloc(count, sizeof(*names), GFP_KERNEL);
if (!names) if (!names)
return; return;
ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
names, gdev->ngpio); names, count);
if (ret < 0) { if (ret < 0) {
dev_warn(&gdev->dev, "failed to read GPIO line names\n"); dev_warn(&gdev->dev, "failed to read GPIO line names\n");
kfree(names); kfree(names);
return; return;
} }
for (i = 0; i < gdev->ngpio; i++) for (i = 0; i < count; i++)
gdev->descs[i].name = names[i]; gdev->descs[i].name = names[i];
kfree(names); kfree(names);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment