Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -29,32 +29,29 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip,
	struct gpio_device *gdev = chip->gpiodev;
	const char **names;
	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);
	if (ret < 0)
	if (count < 0)
		return;

	if (ret != gdev->ngpio) {
		dev_warn(&gdev->dev,
			 "names %d do not match number of GPIOs %d\n", ret,
			 gdev->ngpio);
		return;
	}
	if (count > gdev->ngpio)
		count = gdev->ngpio;

	names = kcalloc(gdev->ngpio, sizeof(*names), GFP_KERNEL);
	names = kcalloc(count, sizeof(*names), GFP_KERNEL);
	if (!names)
		return;

	ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
						names, gdev->ngpio);
						names, count);
	if (ret < 0) {
		dev_warn(&gdev->dev, "failed to read GPIO line names\n");
		kfree(names);
		return;
	}

	for (i = 0; i < gdev->ngpio; i++)
	for (i = 0; i < count; i++)
		gdev->descs[i].name = names[i];

	kfree(names);