From: Fabio Estevam <[email protected]>

Commit e9f2cefb0cdc2ae ("usb: phy: generic: migrate to gpio_desc") broke USB on
imx53-qsb board:

[    0.115456] usb_phy_generic 50000000.aips:usbphy@0: Error requesting RESET 
GPIO
[    0.115554] usb_phy_generic: probe of 50000000.aips:usbphy@0 failed with 
error -2
[    0.115701] usb_phy_generic 50000000.aips:usbphy@1: Error requesting RESET 
GPIO
[    0.115761] usb_phy_generic: probe of 50000000.aips:usbphy@1 failed with 
error -2

Driver should still probe even when 'reset-gpios' property is not passed.

Fix the error handling for devm_gpiod_get() and move the 
"Error requesting RESET GPIO" message right after devm_gpio_request_one().

Signed-off-by: Fabio Estevam <[email protected]>
---
I haven't tested the case when 'reset-gpios' is present yet.

 drivers/usb/phy/phy-generic.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index dd05254..ce1bcdc 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -219,12 +219,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
usb_phy_generic *nop,
 
                needs_vcc = of_property_read_bool(node, "vcc-supply");
                nop->gpiod_reset = devm_gpiod_get(dev, "reset-gpios");
-               err = PTR_ERR(nop->gpiod_reset);
-               if (!err) {
-                       nop->gpiod_vbus = devm_gpiod_get(dev,
-                                                        "vbus-detect-gpio");
-                       err = PTR_ERR(nop->gpiod_vbus);
-               }
+               if (IS_ERR(nop->gpiod_reset))
+                       nop->gpiod_reset = NULL;
+
+               nop->gpiod_vbus = devm_gpiod_get(dev, "vbus-detect-gpio");
+               if (IS_ERR(nop->gpiod_vbus))
+                       nop->gpiod_vbus = NULL;
+
        } else if (pdata) {
                type = pdata->type;
                clk_rate = pdata->clk_rate;
@@ -232,7 +233,10 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
usb_phy_generic *nop,
                if (gpio_is_valid(pdata->gpio_reset)) {
                        err = devm_gpio_request_one(dev, pdata->gpio_reset, 0,
                                                    dev_name(dev));
-                       if (!err)
+
+                       if (err)
+                               dev_err(dev, "Error requesting RESET GPIO\n");
+                       else
                                nop->gpiod_reset =
                                        gpio_to_desc(pdata->gpio_reset);
                }
@@ -241,10 +245,6 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
usb_phy_generic *nop,
 
        if (err == -EPROBE_DEFER)
                return -EPROBE_DEFER;
-       if (err) {
-               dev_err(dev, "Error requesting RESET GPIO\n");
-               return err;
-       }
 
        nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
                        GFP_KERNEL);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to