Re: [PATCH v2 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode

From: Bartosz Golaszewski

Date: Thu May 21 2026 - 05:22:52 EST


On Thu, 21 May 2026 07:13:17 +0200, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> said:
> The sh-pfc driver registers two separate gpiochip instances: one for
> real GPIOs and another for function GPIOs. Since both share the same
> parent platform device, gpiolib's fallback logic causes both chips to
> share the same firmware node (fwnode).
>
> This causes ambiguity when using software nodes to describe GPIOs, as
> gpiolib may apply hogs meant for one chip to the other if they share the
> same node.
>
> Explicitly set gc->fwnode to ERR_PTR(-ENODEV) for the function GPIO
> chip. This satisfies gpiolib's check for an existing fwnode and prevents
> it from falling back to the parent device's node, while ensuring that no
> actual properties or hogs are found on the function chip unless
> explicitly assigned later.
>
> Assisted-by: Gemini:gemini-3.1-pro
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/pinctrl/renesas/gpio.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/pinctrl/renesas/gpio.c b/drivers/pinctrl/renesas/gpio.c
> index 2293af642849..4e59dadb7364 100644
> --- a/drivers/pinctrl/renesas/gpio.c
> +++ b/drivers/pinctrl/renesas/gpio.c
> @@ -278,6 +278,12 @@ static int gpio_function_setup(struct sh_pfc_chip *chip)
>
> gc->request = gpio_function_request;
>
> + /*
> + * Explicitly mask the parent's fwnode to prevent gpiolib from
> + * reusing it for function GPIOs.
> + */
> + gc->fwnode = ERR_PTR(-ENODEV);
> +
> gc->label = pfc->info->name;
> gc->owner = THIS_MODULE;
> gc->base = pfc->nr_gpio_pins;
>
> --
> 2.54.0.669.g59709faab0-goog
>
>

Acked-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

Should we document this behavior in struct gpio_chip's kerneldoc?

Bartosz