diff mbox series

[RFC/PATCH,v2] MIPS: pci: lantiq: switch to using gpiod API

Message ID YzKDFCq3M2gxlJ2e@google.com (mailing list archive)
State Superseded
Headers show
Series [RFC/PATCH,v2] MIPS: pci: lantiq: switch to using gpiod API | expand

Commit Message

Dmitry Torokhov Sept. 27, 2022, 4:59 a.m. UTC
This patch switches the driver from legacy gpio API to the newer
gpiod API.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
v2 - actually compiles.

 arch/mips/pci/pci-lantiq.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

Comments

Thomas Bogendoerfer Sept. 30, 2022, 3:15 p.m. UTC | #1
On Mon, Sep 26, 2022 at 09:59:00PM -0700, Dmitry Torokhov wrote:
> This patch switches the driver from legacy gpio API to the newer
> gpiod API.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> v2 - actually compiles.

I have some doubts...

>  arch/mips/pci/pci-lantiq.c | 27 ++++++++++++---------------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
> index 1ca42f482130..377b4a2577e1 100644
> --- a/arch/mips/pci/pci-lantiq.c
> +++ b/arch/mips/pci/pci-lantiq.c
> @@ -9,11 +9,11 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/mm.h>
>  #include <linux/vmalloc.h>
>  #include <linux/clk.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_gpio.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_pci.h>
>  
> @@ -62,7 +62,7 @@
>  __iomem void *ltq_pci_mapped_cfg;
>  static __iomem void *ltq_pci_membase;
>  
> -static int reset_gpio;
> +static gpio_desc *reset_gpio;

/local/tbogendoerfer/korg/linux/arch/mips/pci/pci-lantiq.c:65:8: error: unknown type name ‘gpio_desc’
 static gpio_desc *reset_gpio;


>  static struct clk *clk_pci, *clk_external;
>  static struct resource pci_io_resource;
>  static struct resource pci_mem_resource;
> @@ -123,17 +123,14 @@ static int ltq_pci_startup(struct platform_device *pdev)
>  		clk_disable(clk_external);
>  
>  	/* setup reset gpio used by pci */
> -	reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
> -	if (gpio_is_valid(reset_gpio)) {
> -		int ret = devm_gpio_request(&pdev->dev,
> -						reset_gpio, "pci-reset");
> -		if (ret) {
> -			dev_err(&pdev->dev,
> -				"failed to request gpio %d\n", reset_gpio);
> -			return ret;
> -		}
> -		gpio_direction_output(reset_gpio, 1);
> +	reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
> +					     GPIOD_OUT_LOW);
> +	ret = PTR_ERR_OR_ZERO(reset_gpio);

/local/tbogendoerfer/korg/linux/arch/mips/pci/pci-lantiq.c:128:2: error: ‘ret’ undeclared (first use in this function)
  ret = PTR_ERR_OR_ZERO(reset_gpio);

Thomas.
Dmitry Torokhov Sept. 30, 2022, 3:52 p.m. UTC | #2
On Fri, Sep 30, 2022 at 05:15:25PM +0200, Thomas Bogendoerfer wrote:
> On Mon, Sep 26, 2022 at 09:59:00PM -0700, Dmitry Torokhov wrote:
> > This patch switches the driver from legacy gpio API to the newer
> > gpiod API.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > v2 - actually compiles.
> 
> I have some doubts...

You are right, I am very sorry as I am not sure how that happened. I did
indeed have a version with the exact errors you pointed out, and I fixed
them. I am not sure how I managed to send the wrong one to you...

I will send out the right one as v3, in the meantime here is what I see
on my end with it:

dtor@dtor-ws:~/kernel/cross-tmp ((b4938080955f...))$ date
Fri Sep 30 08:46:26 AM PDT 2022
dtor@dtor-ws:~/kernel/cross-tmp ((b4938080955f...))$ git log -1 --abbrev --oneline HEAD
b4938080955f (HEAD) MIPS: pci: lantiq: switch to using gpiod API
dtor@dtor-ws:~/kernel/cross-tmp ((b4938080955f...))$ git show HEAD | git patch-id
2f4c9e4f56e674980122ce426c9ca9281eb393a1 b4938080955f015ffd1a8f778ce57b2a8e50c7ba
dtor@dtor-ws:~/kernel/cross-tmp ((b4938080955f...))$ COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross -j1 O=./build_dir_mips ARCH=mips SHELL=/bin/bash arch/mips/pci/pci-lantiq.o
Compiler will be installed in /usr/local/google/home/dtor/0day
make --keep-going CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/usr/local/google/home/dtor/0day/gcc-12.1.0-nolibc/mips-linux/bin/mips-linux- -j1 O=./build_dir_mips ARCH=mips SHELL=/bin/bash arch/mips/pci/pci-lantiq.o
make[1]: Entering directory '/usr/local/google/home/dtor/kernel/cross-tmp/build_dir_mips'
  GEN     Makefile
  CALL    ../scripts/checksyscalls.sh
  CC      arch/mips/pci/pci-lantiq.o
  CC      arch/mips/pci/pci-lantiq.o
make[1]: Leaving directory '/usr/local/google/home/dtor/kernel/cross-tmp/build_dir_mips'

Thanks.
diff mbox series

Patch

diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index 1ca42f482130..377b4a2577e1 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -9,11 +9,11 @@ 
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/clk.h>
 #include <linux/of_platform.h>
-#include <linux/of_gpio.h>
 #include <linux/of_irq.h>
 #include <linux/of_pci.h>
 
@@ -62,7 +62,7 @@ 
 __iomem void *ltq_pci_mapped_cfg;
 static __iomem void *ltq_pci_membase;
 
-static int reset_gpio;
+static gpio_desc *reset_gpio;
 static struct clk *clk_pci, *clk_external;
 static struct resource pci_io_resource;
 static struct resource pci_mem_resource;
@@ -123,17 +123,14 @@  static int ltq_pci_startup(struct platform_device *pdev)
 		clk_disable(clk_external);
 
 	/* setup reset gpio used by pci */
-	reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
-	if (gpio_is_valid(reset_gpio)) {
-		int ret = devm_gpio_request(&pdev->dev,
-						reset_gpio, "pci-reset");
-		if (ret) {
-			dev_err(&pdev->dev,
-				"failed to request gpio %d\n", reset_gpio);
-			return ret;
-		}
-		gpio_direction_output(reset_gpio, 1);
+	reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
+					     GPIOD_OUT_LOW);
+	ret = PTR_ERR_OR_ZERO(reset_gpio);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to request gpio: %d\n", ret);
+		return ret;
 	}
+	gpiod_set_consumer_name(reset_gpio, "pci_reset");
 
 	/* enable auto-switching between PCI and EBU */
 	ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
@@ -195,11 +192,11 @@  static int ltq_pci_startup(struct platform_device *pdev)
 	ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_IEN) | 0x10, LTQ_EBU_PCC_IEN);
 
 	/* toggle reset pin */
-	if (gpio_is_valid(reset_gpio)) {
-		__gpio_set_value(reset_gpio, 0);
+	if (reset_gpio) {
+		gpiod_set_value_cansleep(reset_gpio, 1);
 		wmb();
 		mdelay(1);
-		__gpio_set_value(reset_gpio, 1);
+		gpiod_set_value_cansleep(reset_gpio, 0);
 	}
 	return 0;
 }