I would like to limit (or maybe even remove) use of
[devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned
a bit, so let's switch to the generic device property API. It may even
help with handling secondary fwnodes when gpiolib is taught to handle
gpios described by swnodes.
Signed-off-by: Dmitry Torokhov <[email protected]>
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index 8e323e93be91..929f9363e94b 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
* and in this case fall back to using AFI per port register
* to toggle PERST# SFIO line.
*/
- rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
- "reset-gpios", 0,
- GPIOD_OUT_LOW,
- label);
+ rp->reset_gpio = devm_fwnode_gpiod_get(dev,
+ of_fwnode_handle(port),
+ "reset",
+ GPIOD_OUT_LOW,
+ label);
if (IS_ERR(rp->reset_gpio)) {
if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
rp->reset_gpio = NULL;
--
b4 0.10.0-dev-fc921
On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:
> I would like to limit (or maybe even remove) use of
> [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned
> a bit, so let's switch to the generic device property API. It may even
> help with handling secondary fwnodes when gpiolib is taught to handle
> gpios described by swnodes.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>
>
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index 8e323e93be91..929f9363e94b 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
> * and in this case fall back to using AFI per port register
> * to toggle PERST# SFIO line.
> */
> - rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
> - "reset-gpios", 0,
> - GPIOD_OUT_LOW,
> - label);
> + rp->reset_gpio = devm_fwnode_gpiod_get(dev,
> + of_fwnode_handle(port),
> + "reset",
> + GPIOD_OUT_LOW,
> + label);
Why in pci-aardvark.c for PERST# reset-gpio you have used
devm_gpiod_get_optional() and here in pci-tegra.c you have used
devm_fwnode_gpiod_get()? I think that PERST# logic is same in both
drivers.
> if (IS_ERR(rp->reset_gpio)) {
> if (PTR_ERR(rp->reset_gpio) == -ENOENT) {
> rp->reset_gpio = NULL;
>
> --
> b4 0.10.0-dev-fc921
On Mon, Sep 5, 2022 at 10:23 AM Pali Rohár <[email protected]> wrote:
> On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:
...
> > - rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
> > - "reset-gpios", 0,
> > - GPIOD_OUT_LOW,
> > - label);
> > + rp->reset_gpio = devm_fwnode_gpiod_get(dev,
> > + of_fwnode_handle(port),
> > + "reset",
> > + GPIOD_OUT_LOW,
> > + label);
>
> Why in pci-aardvark.c for PERST# reset-gpio you have used
> devm_gpiod_get_optional() and here in pci-tegra.c you have used
> devm_fwnode_gpiod_get()? I think that PERST# logic is same in both
> drivers.
It's not the same dev and its node in this case. There is one reset
for _all_ ports, here is the reset on _per port_ basis.
--
With Best Regards,
Andy Shevchenko
On Mon, Sep 5, 2022 at 1:49 PM Andy Shevchenko
<[email protected]> wrote:
>
> On Mon, Sep 5, 2022 at 10:23 AM Pali Rohár <[email protected]> wrote:
> > On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:
>
> ...
>
> > > - rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
> > > - "reset-gpios", 0,
> > > - GPIOD_OUT_LOW,
> > > - label);
> > > + rp->reset_gpio = devm_fwnode_gpiod_get(dev,
> > > + of_fwnode_handle(port),
> > > + "reset",
> > > + GPIOD_OUT_LOW,
> > > + label);
> >
> > Why in pci-aardvark.c for PERST# reset-gpio you have used
> > devm_gpiod_get_optional() and here in pci-tegra.c you have used
> > devm_fwnode_gpiod_get()? I think that PERST# logic is same in both
> > drivers.
>
> It's not the same dev and its node in this case. There is one reset
> for _all_ ports, here is the reset on _per port_ basis.
Actually I'm wrong, the aardvark has only one port (?) to serve there.
In any case, here dev == dev->of_node, here dev != port.
--
With Best Regards,
Andy Shevchenko
On Monday 05 September 2022 13:49:21 Andy Shevchenko wrote:
> On Mon, Sep 5, 2022 at 10:23 AM Pali Rohár <[email protected]> wrote:
> > On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:
>
> ...
>
> > > - rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
> > > - "reset-gpios", 0,
> > > - GPIOD_OUT_LOW,
> > > - label);
> > > + rp->reset_gpio = devm_fwnode_gpiod_get(dev,
> > > + of_fwnode_handle(port),
> > > + "reset",
> > > + GPIOD_OUT_LOW,
> > > + label);
> >
> > Why in pci-aardvark.c for PERST# reset-gpio you have used
> > devm_gpiod_get_optional() and here in pci-tegra.c you have used
> > devm_fwnode_gpiod_get()? I think that PERST# logic is same in both
> > drivers.
>
> It's not the same dev and its node in this case. There is one reset
> for _all_ ports, here is the reset on _per port_ basis.
aardvark is single port controller. So it is basically same.
On Mon, Sep 5, 2022 at 1:53 PM Pali Rohár <[email protected]> wrote:
> On Monday 05 September 2022 13:49:21 Andy Shevchenko wrote:
...
> > It's not the same dev and its node in this case. There is one reset
> > for _all_ ports, here is the reset on _per port_ basis.
>
> aardvark is single port controller. So it is basically same.
Yep, just replied to my message.
--
With Best Regards,
Andy Shevchenko
On Mon, Sep 05, 2022 at 09:19:02AM +0200, Pali Roh?r wrote:
> On Sunday 04 September 2022 23:30:53 Dmitry Torokhov wrote:
> > I would like to limit (or maybe even remove) use of
> > [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned
> > a bit, so let's switch to the generic device property API. It may even
> > help with handling secondary fwnodes when gpiolib is taught to handle
> > gpios described by swnodes.
> >
> > Signed-off-by: Dmitry Torokhov <[email protected]>
> >
> > diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> > index 8e323e93be91..929f9363e94b 100644
> > --- a/drivers/pci/controller/pci-tegra.c
> > +++ b/drivers/pci/controller/pci-tegra.c
> > @@ -2202,10 +2202,11 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)
> > * and in this case fall back to using AFI per port register
> > * to toggle PERST# SFIO line.
> > */
> > - rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port,
> > - "reset-gpios", 0,
> > - GPIOD_OUT_LOW,
> > - label);
> > + rp->reset_gpio = devm_fwnode_gpiod_get(dev,
> > + of_fwnode_handle(port),
> > + "reset",
> > + GPIOD_OUT_LOW,
> > + label);
>
> Why in pci-aardvark.c for PERST# reset-gpio you have used
> devm_gpiod_get_optional() and here in pci-tegra.c you have used
> devm_fwnode_gpiod_get()? I think that PERST# logic is same in both
> drivers.
I believe Andy already answered that, but in this driver we can have
several root ports described via subnodes of dev->of_node, and reset
GPIOs are attached to those subnodes. We are forced to use
devm_fwnode_gpiod_get() instead of devm_gpiod_get_optional() as we need
to supply the exact fwnode we need to look up GPIO in, and can not infer
it from the 'dev' parameter of devm_gpiod_get().
Thanks.
--
Dmitry
On Mon, Sep 5, 2022 at 8:31 AM Dmitry Torokhov
<[email protected]> wrote:
> I would like to limit (or maybe even remove) use of
> [devm_]gpiod_get_from_of_node in drivers so that gpiolib can be cleaned
> a bit, so let's switch to the generic device property API. It may even
> help with handling secondary fwnodes when gpiolib is taught to handle
> gpios described by swnodes.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Yours,
Linus Walleij