lantiq: use devm_gpiod_get_optional in PCI driver
authorMathias Kresin <dev@kresin.me>
Thu, 31 Jan 2019 06:52:26 +0000 (07:52 +0100)
committerMathias Kresin <dev@kresin.me>
Mon, 12 Apr 2021 21:37:51 +0000 (23:37 +0200)
Use devm_gpiod_get_optional to aquire the reset gpio and get rid of
quite some code this way.

Since devicetree source files have to be touched to switch to the new
devicetree property, backport a patch fixing the wrong logic in the
reset gpio routines as well.

Signed-off-by: Mathias Kresin <dev@kresin.me>
29 files changed:
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_bt_homehub-v3a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_netgear_dgn3500.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv4510pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv4518pwr01.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv4519pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv4520pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv4525pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv452cqw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv7506pw11.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv7510pw22.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv7518pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv7519pw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv752dpw.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv752dpw22.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv8539pw22.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_bt_homehub-v2b.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_siemens_gigaset-sx76x.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_arcadyan_vgv7510kw22.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_arcadyan_vgv7519.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw8980.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_vr200.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_zyxel_p-2812hnu-fx.dtsi
target/linux/lantiq/patches-5.10/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch [new file with mode: 0644]
target/linux/lantiq/patches-5.10/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch [new file with mode: 0644]
target/linux/lantiq/patches-5.4/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch [new file with mode: 0644]
target/linux/lantiq/patches-5.4/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch [new file with mode: 0644]

index 4a4a06514f480799a5a5bf9eca8481059a03e1da..d368f9fa186fe5d3bc2b1ad73e6999a2936f1a4f 100644 (file)
        pinctrl-names = "default";
 
        req-mask = <0xf>;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
 
        wifi@0,0 {
                compatible = "pci0,0";
index 5f38936577ef6ddf88f6a3be266c7efaec1e5b42..2b34a7ae605adf716801308061adef3af20b849e 100644 (file)
                    <&pci_req3_pins>, <&pci_req4_pins>;
 
        req-mask = <0xf>;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@0,0 {
                compatible = "pci0,0";
index 61a39f9955215619f1ccc9e2f56d42ae34323c9c..4e9502ead762947f588d24c8b62372649ec91c53 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@7000 {
                reg = <0x7000 0 0 0 0>;
index 18168230b6ab4a4ce5ef797f16fea39df4532729..e59d44e9d30e40ee2aeb695b90c2d8b642dac7c1 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@168c,0029 {
                compatible = "pci168c,0029";
index a6a8b93a2454b200cd77efa32cf085332195d89c..e988da14e7f5692030664a1721b5a8d105bce473 100644 (file)
                0x7800 0 0 2 &icu0 66
                0x7800 0 0 3 &icu0 66
        >;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0x7>;
 };
 
index 48fe88fea82b82708bad0691de44944e4cc591a3..39ba89f3c63aca7642a665751bd81ed03ff91d2f 100644 (file)
                    <&pci_req1_pins>, <&pci_req2_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0xf>;
 };
 
index 18a2bfbe83d495f31d074aa6376aba9670574a1e..694d183257bf9428daad6a76f479bf5ea9c2e9a5 100644 (file)
 &pci0 {
        status = "okay";
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0xf>;
 };
 
index 4c76350bdcf87770fdb7992e9b46ee29b000ab74..84b3c349b03ebf63d32ca997eafd7bb72988341b 100644 (file)
        pinctrl-names = "default";
 
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &usb_phy {
index df44abf92f59cd18141738dfd86ce978b96d499a..3a2a3f2df199a99d6dc6ebe344647bdf30c8a4e1 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 /* #define ARV4525PW_RELAY             31 */
index bc04677d46d99b35834fec3513ace44e38d65222..c073d0eb75edf2ab309870ca49f86476c070165e 100644 (file)
        pinctrl-names = "default";
 
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &usb_phy {
index 87954fef02f61b9e20dc551b1e3b5c619ea0ffcd..f86021776d7f95d5aebab764aaf71bd8faba0617 100644 (file)
        pinctrl-names = "default";
 
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@1814,3592 {
                compatible = "pci1814,3592";
index 120dca1834fb480176aa1c17d10f6ef5c161b204..9fd88cce6334472b8068bc2feab0a09778840220 100644 (file)
                0x7800 0 0 2 &icu0 135
                0x7800 0 0 3 &icu0 135
        >;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0x3>;
 
        wifi@1814,3592 {
index f2592961cbf8786cf74b11ffa02790a40bad2e50..b4dcd7f1223c18a171b9f641b500ff57e6b56eca 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        lantiq,external-clock;
        req-mask = <0xf>;
 
index 839af437739bf336ba14e72e11723c1fd9bf5372..45a42c79448d5cb2219e35da7b9538ce61509f90 100644 (file)
        pinctrl-names = "default";
 
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0xf>;
 
        wifi@0,0 {
index d0f5c38b39221fe7f009029c2d78c1a221fd1f73..84b78d7aed14a95f36c827254a249e2b5ff42d64 100644 (file)
        pinctrl-names = "default";
 
        lantiq,external-clock;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        interrupt-map = <0x7000 0 0 1 &icu0 135>;
        req-mask = <0x3>;
 
index 00ac016a42628883a31fb6af90cbe1f98d0e1713..04ca883312ea64dd98915c4dda99313d760fa954 100644 (file)
                0x7800 0 0 2 &icu0 135
                0x7800 0 0 3 &icu0 135
        >;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
        req-mask = <0x3>;
 
        wifi@1814,3592 {
index 5986279e6ed3e7fe178daac30b92fa3136a9bbf6..3b706c23ba5ad9b202a98c29e89d18666f00710b 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@168c,0029 {
                compatible = "pci168c,0029";
index 0147b3ffd1deca63a7263a0acdbec3146809a294..34255576927c44b1cdc3512f3670257d3c4bde9f 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@168c,0027 {
                compatible = "pci168c,0027";
index b2585cf5a7f6fb957f224ff1d1f12617368e9343..3f2614c648b7696f0cd57ac174d527576d064813 100644 (file)
@@ -99,7 +99,7 @@
 
 &pci0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &usb_phy {
index 696a61a861ce02333cd6f80ec47079ad6e615fb3..9d2e9e6e0cea6ce78d563278ed8f218b714ab8fc 100644 (file)
 
 &pci0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@1814,3592 {
                compatible = "pci1814,3592";
index 08d9148fafdcbff4b731e382abff427b971f073e..5df6805e96676c166a9174aaded0a2819905a62a 100644 (file)
 
 &pci0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@1814,3091 {
                compatible = "pci1814,3091";
index f817b3a41b49002ada83b62e8bc2189846252563..e1bda19fd37469e99b00784cb2847ccd48180848 100644 (file)
 
 &pci0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 
        wifi@168c,002d {
                compatible = "pci168c,002d";
index f4a7b8d3c91ebe53ba9c681e6b7d01222eb648e7..3948a3e7eebcd010c603ed21b70140f267debba4 100644 (file)
@@ -27,5 +27,5 @@
        lantiq,bus-clock = <33333333>;
        interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
        interrupt-map = <0x7000 0 0 1 &icu0 30 1>;
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
index aa76f66267f7d215f9c8a5154fc55f82908317e0..ab7eaae2481d028e6c8c5385b61fd406bf90f26f 100644 (file)
 
 &pci0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &spi {
index ee951dc3be735138120c9057b99d463dcf51982d..fc49899a7d00882f2156b3e9324c0a7799e05ac4 100644 (file)
        pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
        pinctrl-names = "default";
 
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &stp {
diff --git a/target/linux/lantiq/patches-5.10/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch b/target/linux/lantiq/patches-5.10/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch
new file mode 100644 (file)
index 0000000..e775d28
--- /dev/null
@@ -0,0 +1,42 @@
+From 2677c39d4d7d3f2e0f716183fc0dc1f6ae4c4d03 Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Wed, 10 Jul 2019 20:27:48 +0200
+Subject: [PATCH 3/6] MIPS: lantiq: pci: fix inverted gpio reset logic
+
+Asserting the reset should be logic 1 and subsequently deasserting the
+reset should be logic 0.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index 8b71b52c959f..c458cc71bc8a 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -141,7 +141,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
+                               "failed to request gpio %d\n", reset_gpio);
+                       return ret;
+               }
+-              gpio_direction_output(reset_gpio, 1);
++              gpio_direction_output(reset_gpio, 0);
+       }
+       /* enable auto-switching between PCI and EBU */
+@@ -205,10 +205,10 @@ static int ltq_pci_startup(struct platform_device *pdev)
+       /* toggle reset pin */
+       if (gpio_is_valid(reset_gpio)) {
+-              __gpio_set_value(reset_gpio, 0);
++              __gpio_set_value(reset_gpio, 1);
+               wmb();
+               mdelay(1);
+-              __gpio_set_value(reset_gpio, 1);
++              __gpio_set_value(reset_gpio, 0);
+       }
+       return 0;
+ }
+-- 
+2.17.1
+
diff --git a/target/linux/lantiq/patches-5.10/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch b/target/linux/lantiq/patches-5.10/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch
new file mode 100644 (file)
index 0000000..ae7740f
--- /dev/null
@@ -0,0 +1,71 @@
+From 23d5f2f840ff7784fa4312447371431c4fe692f2 Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Sat, 2 Feb 2019 22:56:06 +0100
+Subject: [PATCH 4/6] MIPS: lantiq: pci: use devm_gpiod_get_optional
+
+Use devm_gpiod_get_optional to aquire the reset gpio and get rid of
+quite some code this way.
+
+The devicetree property name changes from gpio-reset to reset-gpios due
+to this change. But so far no devicetree source file in the tree uses
+the gpio-reset property.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 24 +++++++++---------------
+ 1 file changed, 9 insertions(+), 15 deletions(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index b246ff067f53..9ce9ac013060 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -64,7 +64,7 @@
+ __iomem void *ltq_pci_mapped_cfg;
+ static __iomem void *ltq_pci_membase;
+-static int reset_gpio;
++static struct gpio_desc *reset_gpio;
+ static struct clk *clk_pci, *clk_external;
+ static struct resource pci_io_resource;
+ static struct resource pci_mem_resource;
+@@ -131,17 +131,11 @@ 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, 0);
+-      }
++      reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
++                                           GPIOD_OUT_LOW);
++      if (IS_ERR(reset_gpio))
++              return dev_err_probe(&pdev->dev, PTR_ERR(reset_gpio),
++                                           "failed to request gpio\n");
+       /* enable auto-switching between PCI and EBU */
+       ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
+@@ -203,11 +197,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, 1);
++      if (reset_gpio) {
++              gpiod_set_value(reset_gpio, 1);
+               wmb();
+               mdelay(1);
+-              __gpio_set_value(reset_gpio, 0);
++              gpiod_set_value(reset_gpio, 0);
+       }
+       return 0;
+ }
+-- 
+2.25.1
+
diff --git a/target/linux/lantiq/patches-5.4/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch b/target/linux/lantiq/patches-5.4/0202-MIPS-lantiq-pci-fix-inverted-gpio-reset-logic.patch
new file mode 100644 (file)
index 0000000..e775d28
--- /dev/null
@@ -0,0 +1,42 @@
+From 2677c39d4d7d3f2e0f716183fc0dc1f6ae4c4d03 Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Wed, 10 Jul 2019 20:27:48 +0200
+Subject: [PATCH 3/6] MIPS: lantiq: pci: fix inverted gpio reset logic
+
+Asserting the reset should be logic 1 and subsequently deasserting the
+reset should be logic 0.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index 8b71b52c959f..c458cc71bc8a 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -141,7 +141,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
+                               "failed to request gpio %d\n", reset_gpio);
+                       return ret;
+               }
+-              gpio_direction_output(reset_gpio, 1);
++              gpio_direction_output(reset_gpio, 0);
+       }
+       /* enable auto-switching between PCI and EBU */
+@@ -205,10 +205,10 @@ static int ltq_pci_startup(struct platform_device *pdev)
+       /* toggle reset pin */
+       if (gpio_is_valid(reset_gpio)) {
+-              __gpio_set_value(reset_gpio, 0);
++              __gpio_set_value(reset_gpio, 1);
+               wmb();
+               mdelay(1);
+-              __gpio_set_value(reset_gpio, 1);
++              __gpio_set_value(reset_gpio, 0);
+       }
+       return 0;
+ }
+-- 
+2.17.1
+
diff --git a/target/linux/lantiq/patches-5.4/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch b/target/linux/lantiq/patches-5.4/0203-MIPS-lantiq-pci-use-devm_gpiod_get_optional.patch
new file mode 100644 (file)
index 0000000..006722e
--- /dev/null
@@ -0,0 +1,72 @@
+From 495589e54437bd1cd34521aae61b17e08bb41e6b Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Sat, 2 Feb 2019 22:56:06 +0100
+Subject: [PATCH 4/6] MIPS: lantiq: pci: use devm_gpiod_get_optional
+
+Use devm_gpiod_get_optional to aquire the reset gpio and get rid of
+quite some code this way.
+
+The devicetree property name changes from gpio-reset to reset-gpios due
+to this change. But so far no devicetree source file in the tree uses
+the gpio-reset property.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 25 +++++++++++--------------
+ 1 file changed, 11 insertions(+), 14 deletions(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index c458cc71bc8a..f4332495b684 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -63,7 +63,7 @@
+ __iomem void *ltq_pci_mapped_cfg;
+ static __iomem void *ltq_pci_membase;
+-static int reset_gpio;
++static struct gpio_desc *reset_gpio;
+ static struct clk *clk_pci, *clk_external;
+ static struct resource pci_io_resource;
+ static struct resource pci_mem_resource;
+@@ -132,16 +132,13 @@ 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, 0);
++      reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
++                                           GPIOD_OUT_LOW);
++      if (IS_ERR(reset_gpio)) {
++              if (PTR_ERR(reset_gpio) != -EPROBE_DEFER)
++                      dev_err(&pdev->dev, "failed to request gpio\n");
++
++              return PTR_ERR(reset_gpio);
+       }
+       /* enable auto-switching between PCI and EBU */
+@@ -204,11 +201,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, 1);
++      if (reset_gpio) {
++              gpiod_set_value(reset_gpio, 1);
+               wmb();
+               mdelay(1);
+-              __gpio_set_value(reset_gpio, 0);
++              gpiod_set_value(reset_gpio, 0);
+       }
+       return 0;
+ }
+-- 
+2.25.1
+