linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci-imx6: replacing legacy gpio interface for gpiod
@ 2021-10-19 15:26 Maíra Canal
  2021-10-19 19:45 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Maíra Canal @ 2021-10-19 15:26 UTC (permalink / raw)
  To: hongxing.zhu, l.stach
  Cc: lorenzo.pieralisi, robh, kw, bhelgaas, shawnguo, s.hauer, kernel,
	festevam, linux-imx, inux-pci, linux-arm-kernel, linux-kernel

Removing all dependencies of linux/gpio.h and linux/of_gpio.h and replacing
it with linux/gpio/consumer.h

Signed-off-by: Maíra Canal <maira.canal@usp.br>
---
 drivers/pci/controller/dwc/pci-imx6.c | 31 ++++++++++-----------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 80fc98acf097..e5ee54e37d05 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -11,13 +11,12 @@
 #include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/kernel.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
 #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
 #include <linux/module.h>
-#include <linux/of_gpio.h>
 #include <linux/of_device.h>
 #include <linux/of_address.h>
 #include <linux/pci.h>
@@ -63,7 +62,7 @@ struct imx6_pcie_drvdata {
 
 struct imx6_pcie {
 	struct dw_pcie		*pci;
-	int			reset_gpio;
+	struct gpio_desc    *reset_gpio;
 	bool			gpio_active_high;
 	struct clk		*pcie_bus;
 	struct clk		*pcie_phy;
@@ -526,11 +525,11 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
 	usleep_range(200, 500);
 
 	/* Some boards don't have PCIe reset GPIO. */
-	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
-		gpio_set_value_cansleep(imx6_pcie->reset_gpio,
+	if (imx6_pcie->reset_gpio) {
+		gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
 					imx6_pcie->gpio_active_high);
 		msleep(100);
-		gpio_set_value_cansleep(imx6_pcie->reset_gpio,
+		gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
 					!imx6_pcie->gpio_active_high);
 	}
 
@@ -1025,22 +1024,14 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 		return PTR_ERR(pci->dbi_base);
 
 	/* Fetch GPIOs */
-	imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0);
 	imx6_pcie->gpio_active_high = of_property_read_bool(node,
 						"reset-gpio-active-high");
-	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
-		ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio,
-				imx6_pcie->gpio_active_high ?
-					GPIOF_OUT_INIT_HIGH :
-					GPIOF_OUT_INIT_LOW,
-				"PCIe reset");
-		if (ret) {
-			dev_err(dev, "unable to get reset gpio\n");
-			return ret;
-		}
-	} else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) {
-		return imx6_pcie->reset_gpio;
-	}
+	imx6_pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
+			imx6_pcie->gpio_active_high ?  GPIOD_OUT_HIGH :
+				GPIOD_OUT_LOW);
+	if (IS_ERR(imx6_pcie->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(imx6_pcie->reset_gpio),
+					  "unable to get reset gpio\n");
 
 	/* Fetch clocks */
 	imx6_pcie->pcie_phy = devm_clk_get(dev, "pcie_phy");
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci-imx6: replacing legacy gpio interface for gpiod
  2021-10-19 15:26 [PATCH] pci-imx6: replacing legacy gpio interface for gpiod Maíra Canal
@ 2021-10-19 19:45 ` Bjorn Helgaas
  2021-10-20 12:02   ` Maíra Canal
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2021-10-19 19:45 UTC (permalink / raw)
  To: Maíra Canal
  Cc: hongxing.zhu, l.stach, lorenzo.pieralisi, robh, kw, bhelgaas,
	shawnguo, s.hauer, kernel, festevam, linux-imx, linux-pci,
	linux-arm-kernel, linux-kernel

[fixed "linux-pci@vger.kernel.org" in cc]

On Tue, Oct 19, 2021 at 12:26:53PM -0300, Maíra Canal wrote:
> Removing all dependencies of linux/gpio.h and linux/of_gpio.h and replacing
> it with linux/gpio/consumer.h

Run "git log --oneline drivers/pci/controller/dwc/pci-imx6.c" and make
your subject line match -- capitalization, sentence structure, etc.

Write commit log in imperative mood, i.e., "Remove" instead of
"Removing": https://chris.beams.io/posts/git-commit/

The commit log mentions the trivial part but omits the important part
(converting from gpio to gpiod model).

> Signed-off-by: Maíra Canal <maira.canal@usp.br>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 31 ++++++++++-----------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 80fc98acf097..e5ee54e37d05 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -11,13 +11,12 @@
>  #include <linux/bitfield.h>
>  #include <linux/clk.h>
>  #include <linux/delay.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/kernel.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
>  #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
>  #include <linux/module.h>
> -#include <linux/of_gpio.h>
>  #include <linux/of_device.h>
>  #include <linux/of_address.h>
>  #include <linux/pci.h>
> @@ -63,7 +62,7 @@ struct imx6_pcie_drvdata {
>  
>  struct imx6_pcie {
>  	struct dw_pcie		*pci;
> -	int			reset_gpio;
> +	struct gpio_desc    *reset_gpio;
>  	bool			gpio_active_high;
>  	struct clk		*pcie_bus;
>  	struct clk		*pcie_phy;
> @@ -526,11 +525,11 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
>  	usleep_range(200, 500);
>  
>  	/* Some boards don't have PCIe reset GPIO. */
> -	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
> -		gpio_set_value_cansleep(imx6_pcie->reset_gpio,
> +	if (imx6_pcie->reset_gpio) {
> +		gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
>  					imx6_pcie->gpio_active_high);
>  		msleep(100);
> -		gpio_set_value_cansleep(imx6_pcie->reset_gpio,
> +		gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
>  					!imx6_pcie->gpio_active_high);
>  	}
>  
> @@ -1025,22 +1024,14 @@ static int imx6_pcie_probe(struct platform_device *pdev)
>  		return PTR_ERR(pci->dbi_base);
>  
>  	/* Fetch GPIOs */
> -	imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0);
>  	imx6_pcie->gpio_active_high = of_property_read_bool(node,
>  						"reset-gpio-active-high");
> -	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
> -		ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio,
> -				imx6_pcie->gpio_active_high ?
> -					GPIOF_OUT_INIT_HIGH :
> -					GPIOF_OUT_INIT_LOW,
> -				"PCIe reset");
> -		if (ret) {
> -			dev_err(dev, "unable to get reset gpio\n");
> -			return ret;
> -		}
> -	} else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) {
> -		return imx6_pcie->reset_gpio;
> -	}
> +	imx6_pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> +			imx6_pcie->gpio_active_high ?  GPIOD_OUT_HIGH :
> +				GPIOD_OUT_LOW);
> +	if (IS_ERR(imx6_pcie->reset_gpio))
> +		return dev_err_probe(dev, PTR_ERR(imx6_pcie->reset_gpio),
> +					  "unable to get reset gpio\n");
>  
>  	/* Fetch clocks */
>  	imx6_pcie->pcie_phy = devm_clk_get(dev, "pcie_phy");
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pci-imx6: replacing legacy gpio interface for gpiod
  2021-10-19 19:45 ` Bjorn Helgaas
@ 2021-10-20 12:02   ` Maíra Canal
  0 siblings, 0 replies; 3+ messages in thread
From: Maíra Canal @ 2021-10-20 12:02 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: hongxing.zhu, l.stach, lorenzo.pieralisi, robh, kw,
	Bjorn Helgaas, shawnguo, s.hauer, kernel, festevam, linux-imx,
	linux-pci, linux-arm-kernel, linux-kernel

I'm sorry about the commit log. I made an effort to do a better commit
log on v2 and sent the new version on the mailing list. Thanks for
reviewing the entry!


Em ter., 19 de out. de 2021 às 16:45, Bjorn Helgaas
<helgaas@kernel.org> escreveu:
>
> [fixed "linux-pci@vger.kernel.org" in cc]
>
> On Tue, Oct 19, 2021 at 12:26:53PM -0300, Maíra Canal wrote:
> > Removing all dependencies of linux/gpio.h and linux/of_gpio.h and replacing
> > it with linux/gpio/consumer.h
>
> Run "git log --oneline drivers/pci/controller/dwc/pci-imx6.c" and make
> your subject line match -- capitalization, sentence structure, etc.
>
> Write commit log in imperative mood, i.e., "Remove" instead of
> "Removing": https://chris.beams.io/posts/git-commit/
>
> The commit log mentions the trivial part but omits the important part
> (converting from gpio to gpiod model).
>
> > Signed-off-by: Maíra Canal <maira.canal@usp.br>
> > ---
> >  drivers/pci/controller/dwc/pci-imx6.c | 31 ++++++++++-----------------
> >  1 file changed, 11 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> > index 80fc98acf097..e5ee54e37d05 100644
> > --- a/drivers/pci/controller/dwc/pci-imx6.c
> > +++ b/drivers/pci/controller/dwc/pci-imx6.c
> > @@ -11,13 +11,12 @@
> >  #include <linux/bitfield.h>
> >  #include <linux/clk.h>
> >  #include <linux/delay.h>
> > -#include <linux/gpio.h>
> > +#include <linux/gpio/consumer.h>
> >  #include <linux/kernel.h>
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
> >  #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
> >  #include <linux/module.h>
> > -#include <linux/of_gpio.h>
> >  #include <linux/of_device.h>
> >  #include <linux/of_address.h>
> >  #include <linux/pci.h>
> > @@ -63,7 +62,7 @@ struct imx6_pcie_drvdata {
> >
> >  struct imx6_pcie {
> >       struct dw_pcie          *pci;
> > -     int                     reset_gpio;
> > +     struct gpio_desc    *reset_gpio;
> >       bool                    gpio_active_high;
> >       struct clk              *pcie_bus;
> >       struct clk              *pcie_phy;
> > @@ -526,11 +525,11 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
> >       usleep_range(200, 500);
> >
> >       /* Some boards don't have PCIe reset GPIO. */
> > -     if (gpio_is_valid(imx6_pcie->reset_gpio)) {
> > -             gpio_set_value_cansleep(imx6_pcie->reset_gpio,
> > +     if (imx6_pcie->reset_gpio) {
> > +             gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
> >                                       imx6_pcie->gpio_active_high);
> >               msleep(100);
> > -             gpio_set_value_cansleep(imx6_pcie->reset_gpio,
> > +             gpiod_set_value_cansleep(imx6_pcie->reset_gpio,
> >                                       !imx6_pcie->gpio_active_high);
> >       }
> >
> > @@ -1025,22 +1024,14 @@ static int imx6_pcie_probe(struct platform_device *pdev)
> >               return PTR_ERR(pci->dbi_base);
> >
> >       /* Fetch GPIOs */
> > -     imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0);
> >       imx6_pcie->gpio_active_high = of_property_read_bool(node,
> >                                               "reset-gpio-active-high");
> > -     if (gpio_is_valid(imx6_pcie->reset_gpio)) {
> > -             ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio,
> > -                             imx6_pcie->gpio_active_high ?
> > -                                     GPIOF_OUT_INIT_HIGH :
> > -                                     GPIOF_OUT_INIT_LOW,
> > -                             "PCIe reset");
> > -             if (ret) {
> > -                     dev_err(dev, "unable to get reset gpio\n");
> > -                     return ret;
> > -             }
> > -     } else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) {
> > -             return imx6_pcie->reset_gpio;
> > -     }
> > +     imx6_pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> > +                     imx6_pcie->gpio_active_high ?  GPIOD_OUT_HIGH :
> > +                             GPIOD_OUT_LOW);
> > +     if (IS_ERR(imx6_pcie->reset_gpio))
> > +             return dev_err_probe(dev, PTR_ERR(imx6_pcie->reset_gpio),
> > +                                       "unable to get reset gpio\n");
> >
> >       /* Fetch clocks */
> >       imx6_pcie->pcie_phy = devm_clk_get(dev, "pcie_phy");
> > --
> > 2.31.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-20 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 15:26 [PATCH] pci-imx6: replacing legacy gpio interface for gpiod Maíra Canal
2021-10-19 19:45 ` Bjorn Helgaas
2021-10-20 12:02   ` Maíra Canal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).