Commit acc6e331 authored by Thierry Reding's avatar Thierry Reding Committed by Linus Walleij

gpio: of: Allow overriding the device node

When registering a GPIO chip, drivers can override the device tree node
associated with the chip by setting the chip's ->of_node field. If set,
this field is supposed to take precedence over the ->parent->of_node
field, but the code doesn't actually do that.

Commit 762c2e46 ("gpio: of: remove of_gpiochip_and_xlate() and
struct gg_data") exposes this because it now no longer matches on the
GPIO chip's ->of_node field, but the GPIO device's ->of_node field that
is set using the procedure described above.
Signed-off-by: default avatarThierry Reding <>
Acked-by: default avatarAlexandre Courbot <>
Reviewed-by: default avatarMasahiro Yamada <>
Signed-off-by: Linus Walleij's avatarLinus Walleij <>
parent d932cd49
......@@ -1049,13 +1049,14 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
if (chip->parent) {
gdev->dev.parent = chip->parent;
gdev->dev.of_node = chip->parent->of_node;
} else {
/* If the gpiochip has an assigned OF node this takes precedence */
if (chip->of_node)
gdev->dev.of_node = chip->of_node;
if (chip->of_node)
gdev->dev.of_node = chip->of_node;
gdev->id = ida_simple_get(&gpio_ida, 0, 0, GFP_KERNEL);
if (gdev->id < 0) {
status = gdev->id;
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