gpio: fix "gpio-line-names" property retrieval

Following commit 9427ecbed46cc ("gpio: Rework of_gpiochip_set_names()
to use device property accessors"), "gpio-line-names" DT property is
not retrieved anymore when chip->parent is not set by the driver.
This is due to OF based property reads having been replaced by device
based property reads.

This patch fixes that by making use of
fwnode_property_read_string_array() instead of
device_property_read_string_array() and handing over either
of_fwnode_handle(chip->of_node) or dev_fwnode(chip->parent)
to that function.

Fixes: 9427ecbed46cc ("gpio: Rework of_gpiochip_set_names() to use device property accessors")
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by Christophe Leroy and committed by Linus Walleij 82270335 8bb65fc0

+12 -13
+1 -1
drivers/gpio/gpiolib-acpi.c
··· 1074 1074 } 1075 1075 1076 1076 if (!chip->names) 1077 - devprop_gpiochip_set_names(chip); 1077 + devprop_gpiochip_set_names(chip, dev_fwnode(chip->parent)); 1078 1078 1079 1079 acpi_gpiochip_request_regions(acpi_gpio); 1080 1080 acpi_gpiochip_scan_gpios(acpi_gpio);
+7 -10
drivers/gpio/gpiolib-devprop.c
··· 19 19 /** 20 20 * devprop_gpiochip_set_names - Set GPIO line names using device properties 21 21 * @chip: GPIO chip whose lines should be named, if possible 22 + * @fwnode: Property Node containing the gpio-line-names property 22 23 * 23 24 * Looks for device property "gpio-line-names" and if it exists assigns 24 25 * GPIO line names for the chip. The memory allocated for the assigned 25 26 * names belong to the underlying firmware node and should not be released 26 27 * by the caller. 27 28 */ 28 - void devprop_gpiochip_set_names(struct gpio_chip *chip) 29 + void devprop_gpiochip_set_names(struct gpio_chip *chip, 30 + const struct fwnode_handle *fwnode) 29 31 { 30 32 struct gpio_device *gdev = chip->gpiodev; 31 33 const char **names; 32 34 int ret, i; 33 35 34 - if (!chip->parent) { 35 - dev_warn(&gdev->dev, "GPIO chip parent is NULL\n"); 36 - return; 37 - } 38 - 39 - ret = device_property_read_string_array(chip->parent, "gpio-line-names", 36 + ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", 40 37 NULL, 0); 41 38 if (ret < 0) 42 39 return; 43 40 44 41 if (ret != gdev->ngpio) { 45 - dev_warn(chip->parent, 42 + dev_warn(&gdev->dev, 46 43 "names %d do not match number of GPIOs %d\n", ret, 47 44 gdev->ngpio); 48 45 return; ··· 49 52 if (!names) 50 53 return; 51 54 52 - ret = device_property_read_string_array(chip->parent, "gpio-line-names", 55 + ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", 53 56 names, gdev->ngpio); 54 57 if (ret < 0) { 55 - dev_warn(chip->parent, "failed to read GPIO line names\n"); 58 + dev_warn(&gdev->dev, "failed to read GPIO line names\n"); 56 59 kfree(names); 57 60 return; 58 61 }
+2 -1
drivers/gpio/gpiolib-of.c
··· 493 493 494 494 /* If the chip defines names itself, these take precedence */ 495 495 if (!chip->names) 496 - devprop_gpiochip_set_names(chip); 496 + devprop_gpiochip_set_names(chip, 497 + of_fwnode_handle(chip->of_node)); 497 498 498 499 of_node_get(chip->of_node); 499 500
+2 -1
drivers/gpio/gpiolib.h
··· 228 228 return desc - &desc->gdev->descs[0]; 229 229 } 230 230 231 - void devprop_gpiochip_set_names(struct gpio_chip *chip); 231 + void devprop_gpiochip_set_names(struct gpio_chip *chip, 232 + const struct fwnode_handle *fwnode); 232 233 233 234 /* With descriptor prefix */ 234 235