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

Bartosz Golaszewski <[email protected]>
Newsgroups gmane.linux.kernel.renesas-soc,gmane.linux.ports.sh.devel,gmane.linux.kernel,gmane.linux.kernel.gpio
Message-ID <CAMRc=Mcu+UTGz5keKgHqo4BdWMtK87CLiVU1jWBoLHNABJc2sA@mail.gmail.com>
On Thu, 21 May 2026 07:13:17 +0200, Dmitry Torokhov
<[email protected]> 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 <[email protected]>
> ---
>  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 <[email protected]>

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

Bartosz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.