Skip to content

Commit b41ba2e

Browse files
andy-shevbrgl
authored andcommitted
gpiolib: Read "gpio-line-names" from a firmware node
On STM32MP1, the GPIO banks are subnodes of pin-controller@50002000, see arch/arm/boot/dts/stm32mp151.dtsi. The driver for pin-controller@50002000 is in drivers/pinctrl/stm32/pinctrl-stm32.c and iterates over all of its DT subnodes when registering each GPIO bank gpiochip. Each gpiochip has: - gpio_chip.parent = dev, where dev is the device node of the pin controller - gpio_chip.of_node = np, which is the OF node of the GPIO bank Therefore, dev_fwnode(chip->parent) != of_fwnode_handle(chip.of_node), i.e. pin-controller@50002000 != pin-controller@50002000/gpio@5000*000. The original code behaved correctly, as it extracted the "gpio-line-names" from of_fwnode_handle(chip.of_node) = pin-controller@50002000/gpio@5000*000. To achieve the same behaviour, read property from the firmware node. Fixes: 7cba1a4 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Reported-by: Marek Vasut <marex@denx.de> Reported-by: Roman Guskov <rguskov@dh-electronics.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Marek Vasut <marex@denx.de> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
1 parent eb44133 commit b41ba2e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/gpio/gpiolib.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,22 +367,18 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
367367
*
368368
* Looks for device property "gpio-line-names" and if it exists assigns
369369
* GPIO line names for the chip. The memory allocated for the assigned
370-
* names belong to the underlying software node and should not be released
370+
* names belong to the underlying firmware node and should not be released
371371
* by the caller.
372372
*/
373373
static int devprop_gpiochip_set_names(struct gpio_chip *chip)
374374
{
375375
struct gpio_device *gdev = chip->gpiodev;
376-
struct device *dev = chip->parent;
376+
struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);
377377
const char **names;
378378
int ret, i;
379379
int count;
380380

381-
/* GPIO chip may not have a parent device whose properties we inspect. */
382-
if (!dev)
383-
return 0;
384-
385-
count = device_property_string_array_count(dev, "gpio-line-names");
381+
count = fwnode_property_string_array_count(fwnode, "gpio-line-names");
386382
if (count < 0)
387383
return 0;
388384

@@ -396,7 +392,7 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
396392
if (!names)
397393
return -ENOMEM;
398394

399-
ret = device_property_read_string_array(dev, "gpio-line-names",
395+
ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
400396
names, count);
401397
if (ret < 0) {
402398
dev_warn(&gdev->dev, "failed to read GPIO line names\n");

0 commit comments

Comments
 (0)