Commit 82270335 authored by Christophe Leroy's avatar Christophe Leroy Committed by Linus Walleij

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

Following commit 9427ecbe ("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: 9427ecbe ("gpio: Rework of_gpiochip_set_names() to use device property accessors")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 8bb65fc0
...@@ -1074,7 +1074,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip) ...@@ -1074,7 +1074,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)
} }
if (!chip->names) if (!chip->names)
devprop_gpiochip_set_names(chip); devprop_gpiochip_set_names(chip, dev_fwnode(chip->parent));
acpi_gpiochip_request_regions(acpi_gpio); acpi_gpiochip_request_regions(acpi_gpio);
acpi_gpiochip_scan_gpios(acpi_gpio); acpi_gpiochip_scan_gpios(acpi_gpio);
......
...@@ -19,30 +19,27 @@ ...@@ -19,30 +19,27 @@
/** /**
* devprop_gpiochip_set_names - Set GPIO line names using device properties * devprop_gpiochip_set_names - Set GPIO line names using device properties
* @chip: GPIO chip whose lines should be named, if possible * @chip: GPIO chip whose lines should be named, if possible
* @fwnode: Property Node containing the gpio-line-names property
* *
* Looks for device property "gpio-line-names" and if it exists assigns * Looks for device property "gpio-line-names" and if it exists assigns
* GPIO line names for the chip. The memory allocated for the assigned * GPIO line names for the chip. The memory allocated for the assigned
* names belong to the underlying firmware node and should not be released * names belong to the underlying firmware node and should not be released
* by the caller. * by the caller.
*/ */
void devprop_gpiochip_set_names(struct gpio_chip *chip) void devprop_gpiochip_set_names(struct gpio_chip *chip,
const struct fwnode_handle *fwnode)
{ {
struct gpio_device *gdev = chip->gpiodev; struct gpio_device *gdev = chip->gpiodev;
const char **names; const char **names;
int ret, i; int ret, i;
if (!chip->parent) { ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
dev_warn(&gdev->dev, "GPIO chip parent is NULL\n");
return;
}
ret = device_property_read_string_array(chip->parent, "gpio-line-names",
NULL, 0); NULL, 0);
if (ret < 0) if (ret < 0)
return; return;
if (ret != gdev->ngpio) { if (ret != gdev->ngpio) {
dev_warn(chip->parent, dev_warn(&gdev->dev,
"names %d do not match number of GPIOs %d\n", ret, "names %d do not match number of GPIOs %d\n", ret,
gdev->ngpio); gdev->ngpio);
return; return;
...@@ -52,10 +49,10 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip) ...@@ -52,10 +49,10 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip)
if (!names) if (!names)
return; return;
ret = device_property_read_string_array(chip->parent, "gpio-line-names", ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
names, gdev->ngpio); names, gdev->ngpio);
if (ret < 0) { if (ret < 0) {
dev_warn(chip->parent, "failed to read GPIO line names\n"); dev_warn(&gdev->dev, "failed to read GPIO line names\n");
kfree(names); kfree(names);
return; return;
} }
......
...@@ -493,7 +493,8 @@ int of_gpiochip_add(struct gpio_chip *chip) ...@@ -493,7 +493,8 @@ int of_gpiochip_add(struct gpio_chip *chip)
/* If the chip defines names itself, these take precedence */ /* If the chip defines names itself, these take precedence */
if (!chip->names) if (!chip->names)
devprop_gpiochip_set_names(chip); devprop_gpiochip_set_names(chip,
of_fwnode_handle(chip->of_node));
of_node_get(chip->of_node); of_node_get(chip->of_node);
......
...@@ -228,7 +228,8 @@ static inline int gpio_chip_hwgpio(const struct gpio_desc *desc) ...@@ -228,7 +228,8 @@ static inline int gpio_chip_hwgpio(const struct gpio_desc *desc)
return desc - &desc->gdev->descs[0]; return desc - &desc->gdev->descs[0];
} }
void devprop_gpiochip_set_names(struct gpio_chip *chip); void devprop_gpiochip_set_names(struct gpio_chip *chip,
const struct fwnode_handle *fwnode);
/* With descriptor prefix */ /* With descriptor prefix */
......
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