* [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip @ 2023-10-09 17:38 Dipen Patel 2023-10-10 13:13 ` Andy Shevchenko 0 siblings, 1 reply; 7+ messages in thread From: Dipen Patel @ 2023-10-09 17:38 UTC (permalink / raw) To: linus.walleij, brgl, andy, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel Cc: Dipen Patel Any driver that depends on the GPIO match function to locate the GPIO controller, it has to use the fwnode from the gpio_chip structure. But with [1], it is GPIO providers job to set any members of the gpio_chip structure. This patch addresses that. [1] https://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/linux.git/patch/drivers/gpio/gpiolib.c?id=daecca4b8433d47f0db4933bcc0f283d530ba22e Signed-off-by: Dipen Patel <dipenp@nvidia.com> --- drivers/gpio/gpio-tegra186.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c index d87dd06db40d..86ad34e07841 100644 --- a/drivers/gpio/gpio-tegra186.c +++ b/drivers/gpio/gpio-tegra186.c @@ -989,6 +989,12 @@ static int tegra186_gpio_probe(struct platform_device *pdev) offset += port->pins; } + /* + * This is needed for driver using gpio device matching where it + * has to use gpio_chip fwnode to match the gpio controller. + */ + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); + return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio, gpio); } -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-09 17:38 [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip Dipen Patel @ 2023-10-10 13:13 ` Andy Shevchenko 2023-10-10 13:48 ` Andy Shevchenko 0 siblings, 1 reply; 7+ messages in thread From: Andy Shevchenko @ 2023-10-10 13:13 UTC (permalink / raw) To: Dipen Patel Cc: linus.walleij, brgl, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: Tbank you! My comments below. > Any driver that depends on the GPIO match function to locate the GPIO > controller, it has to use the fwnode from the gpio_chip structure. But > with [1], it is GPIO providers job to set any members of the gpio_chip > structure. This patch addresses that. > [1] https://git.kernel.org/pub/scm/linux/kernel/git/pateldipen1984/linux.git/patch/drivers/gpio/gpiolib.c?id=daecca4b8433d47f0db4933bcc0f283d530ba22e Use Link: tag for this? ... > + /* > + * This is needed for driver using gpio device matching where it > + * has to use gpio_chip fwnode to match the gpio controller. > + */ > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); of_node_to_fwnode() is specific to IRQ, in other places we use generic of_fwnode_handle(). That's why better just to use dev_fwnode(). ... With the above addressed: Reviewed-by: Andy Shevchenko <andy@kernel.org> -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-10 13:13 ` Andy Shevchenko @ 2023-10-10 13:48 ` Andy Shevchenko 2023-10-10 14:13 ` Andy Shevchenko 0 siblings, 1 reply; 7+ messages in thread From: Andy Shevchenko @ 2023-10-10 13:48 UTC (permalink / raw) To: Dipen Patel Cc: linus.walleij, brgl, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Tue, Oct 10, 2023 at 04:13:19PM +0300, Andy Shevchenko wrote: > On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: ... > > + /* > > + * This is needed for driver using gpio device matching where it > > + * has to use gpio_chip fwnode to match the gpio controller. > > + */ > > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); > > of_node_to_fwnode() is specific to IRQ, in other places we use generic > of_fwnode_handle(). That's why better just to use dev_fwnode(). On the second thought is there any parent assigned? At least I see that in tegra186_gpio_probe(). Are you saying it is not working? Or is it (matching) called _before_ we add a GPIO device? -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-10 13:48 ` Andy Shevchenko @ 2023-10-10 14:13 ` Andy Shevchenko 2023-10-10 14:25 ` Andy Shevchenko 0 siblings, 1 reply; 7+ messages in thread From: Andy Shevchenko @ 2023-10-10 14:13 UTC (permalink / raw) To: Dipen Patel Cc: linus.walleij, brgl, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Tue, Oct 10, 2023 at 04:48:25PM +0300, Andy Shevchenko wrote: > On Tue, Oct 10, 2023 at 04:13:19PM +0300, Andy Shevchenko wrote: > > On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: ... > > > + /* > > > + * This is needed for driver using gpio device matching where it > > > + * has to use gpio_chip fwnode to match the gpio controller. > > > + */ > > > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); > > > > of_node_to_fwnode() is specific to IRQ, in other places we use generic > > of_fwnode_handle(). That's why better just to use dev_fwnode(). > > On the second thought is there any parent assigned? > At least I see that in tegra186_gpio_probe(). Are you saying > it is not working? Or is it (matching) called _before_ we > add a GPIO device? Okay, I think I got it. There is a function called tegra_gpiochip_match() in drivers/hte/hte-tegra194.c which fails after my patch. Yeah, if provider doesn't set fwnode, it can't match. But, since the driver sets the parent properly it means that the matching function should be done against the device. Seems to me that in HTE code the matching function is broken. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-10 14:13 ` Andy Shevchenko @ 2023-10-10 14:25 ` Andy Shevchenko 2023-10-10 15:10 ` Bartosz Golaszewski 0 siblings, 1 reply; 7+ messages in thread From: Andy Shevchenko @ 2023-10-10 14:25 UTC (permalink / raw) To: Dipen Patel Cc: linus.walleij, brgl, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Tue, Oct 10, 2023 at 05:13:42PM +0300, Andy Shevchenko wrote: > On Tue, Oct 10, 2023 at 04:48:25PM +0300, Andy Shevchenko wrote: > > On Tue, Oct 10, 2023 at 04:13:19PM +0300, Andy Shevchenko wrote: > > > On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: ... > > > > + /* > > > > + * This is needed for driver using gpio device matching where it > > > > + * has to use gpio_chip fwnode to match the gpio controller. > > > > + */ > > > > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); > > > > > > of_node_to_fwnode() is specific to IRQ, in other places we use generic > > > of_fwnode_handle(). That's why better just to use dev_fwnode(). > > > > On the second thought is there any parent assigned? > > At least I see that in tegra186_gpio_probe(). Are you saying > > it is not working? Or is it (matching) called _before_ we > > add a GPIO device? > > Okay, I think I got it. There is a function called tegra_gpiochip_match() > in drivers/hte/hte-tegra194.c which fails after my patch. Yeah, if provider > doesn't set fwnode, it can't match. But, since the driver sets the parent > properly it means that the matching function should be done against the > device. > > Seems to me that in HTE code the matching function is broken. I'll send a patch soon. Please, test it. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-10 14:25 ` Andy Shevchenko @ 2023-10-10 15:10 ` Bartosz Golaszewski 2023-10-10 15:18 ` Andy Shevchenko 0 siblings, 1 reply; 7+ messages in thread From: Bartosz Golaszewski @ 2023-10-10 15:10 UTC (permalink / raw) To: Andy Shevchenko Cc: Dipen Patel, linus.walleij, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Tue, Oct 10, 2023 at 4:25 PM Andy Shevchenko <andy@kernel.org> wrote: > > On Tue, Oct 10, 2023 at 05:13:42PM +0300, Andy Shevchenko wrote: > > On Tue, Oct 10, 2023 at 04:48:25PM +0300, Andy Shevchenko wrote: > > > On Tue, Oct 10, 2023 at 04:13:19PM +0300, Andy Shevchenko wrote: > > > > On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: > > ... > > > > > > + /* > > > > > + * This is needed for driver using gpio device matching where it > > > > > + * has to use gpio_chip fwnode to match the gpio controller. > > > > > + */ > > > > > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); > > > > > > > > of_node_to_fwnode() is specific to IRQ, in other places we use generic > > > > of_fwnode_handle(). That's why better just to use dev_fwnode(). > > > > > > On the second thought is there any parent assigned? > > > At least I see that in tegra186_gpio_probe(). Are you saying > > > it is not working? Or is it (matching) called _before_ we > > > add a GPIO device? > > > > Okay, I think I got it. There is a function called tegra_gpiochip_match() > > in drivers/hte/hte-tegra194.c which fails after my patch. Yeah, if provider > > doesn't set fwnode, it can't match. But, since the driver sets the parent > > properly it means that the matching function should be done against the > > device. > > > > Seems to me that in HTE code the matching function is broken. > > I'll send a patch soon. Please, test it. > I'll have you know that if it is about to add any new "#include ../gpio/gpiolib.h", then it's a preemptive NAK from me. :) Bart ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip 2023-10-10 15:10 ` Bartosz Golaszewski @ 2023-10-10 15:18 ` Andy Shevchenko 0 siblings, 0 replies; 7+ messages in thread From: Andy Shevchenko @ 2023-10-10 15:18 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Dipen Patel, linus.walleij, thierry.reding, jonathanh, linux-gpio, linux-tegra, linux-kernel On Tue, Oct 10, 2023 at 05:10:08PM +0200, Bartosz Golaszewski wrote: > On Tue, Oct 10, 2023 at 4:25 PM Andy Shevchenko <andy@kernel.org> wrote: > > On Tue, Oct 10, 2023 at 05:13:42PM +0300, Andy Shevchenko wrote: > > > On Tue, Oct 10, 2023 at 04:48:25PM +0300, Andy Shevchenko wrote: > > > > On Tue, Oct 10, 2023 at 04:13:19PM +0300, Andy Shevchenko wrote: > > > > > On Mon, Oct 09, 2023 at 10:38:58AM -0700, Dipen Patel wrote: ... > > > > > > + /* > > > > > > + * This is needed for driver using gpio device matching where it > > > > > > + * has to use gpio_chip fwnode to match the gpio controller. > > > > > > + */ > > > > > > + gpio->gpio.fwnode = of_node_to_fwnode(pdev->dev.of_node); > > > > > > > > > > of_node_to_fwnode() is specific to IRQ, in other places we use generic > > > > > of_fwnode_handle(). That's why better just to use dev_fwnode(). > > > > > > > > On the second thought is there any parent assigned? > > > > At least I see that in tegra186_gpio_probe(). Are you saying > > > > it is not working? Or is it (matching) called _before_ we > > > > add a GPIO device? > > > > > > Okay, I think I got it. There is a function called tegra_gpiochip_match() > > > in drivers/hte/hte-tegra194.c which fails after my patch. Yeah, if provider > > > doesn't set fwnode, it can't match. But, since the driver sets the parent > > > properly it means that the matching function should be done against the > > > device. > > > > > > Seems to me that in HTE code the matching function is broken. > > > > I'll send a patch soon. Please, test it. > > I'll have you know that if it is about to add any new "#include > ../gpio/gpiolib.h", then it's a preemptive NAK from me. :) Nope, see I just sent it. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-10-10 15:18 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-09 17:38 [PATCH 1/1] gpio: tegra186: Set fwnode of the GPIO chip Dipen Patel 2023-10-10 13:13 ` Andy Shevchenko 2023-10-10 13:48 ` Andy Shevchenko 2023-10-10 14:13 ` Andy Shevchenko 2023-10-10 14:25 ` Andy Shevchenko 2023-10-10 15:10 ` Bartosz Golaszewski 2023-10-10 15:18 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox