From: Dinh Nguyen <dingu...@altera.com>

Since the dwc2 hcd driver is currently not looking for a clock node during
init, we should not completely fail if there isn't a clock provided.
Add a check for a valid clock before calling clock functions.

Signed-off-by: Dinh Nguyen <dingu...@altera.com>
---
 drivers/usb/dwc2/gadget.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ca5c64a..51ee052 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3228,16 +3228,15 @@ static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, 
int irq)
                dwc2->s3c_hsotg->phy = phy;
 
        dwc2->s3c_hsotg->clk = devm_clk_get(dev, "otg");
-       if (IS_ERR(dwc2->s3c_hsotg->clk)) {
-               dev_err(dev, "cannot get otg clock\n");
-               return PTR_ERR(dwc2->s3c_hsotg->clk);
-       }
+       if (IS_ERR(dwc2->s3c_hsotg->clk))
+               dev_warn(dev, "cannot get otg clock\n");
 
        dwc2->gadget.max_speed = USB_SPEED_HIGH;
        dwc2->gadget.ops = &s3c_hsotg_gadget_ops;
        dwc2->gadget.name = dev_name(dev);
 
-       clk_prepare_enable(dwc2->s3c_hsotg->clk);
+       if (dwc2->s3c_hsotg->clk)
+               clk_prepare_enable(dwc2->s3c_hsotg->clk);
 
        /* regulators */
 
@@ -3342,7 +3341,8 @@ err_ep_mem:
 err_supplies:
        s3c_hsotg_phy_disable(dwc2);
 err_clk:
-       clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+       if (dwc2->s3c_hsotg->clk)
+               clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
        return ret;
 }
@@ -3365,7 +3365,8 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
        s3c_hsotg_phy_disable(dwc2);
        if (dwc2->s3c_hsotg->phy)
                phy_exit(dwc2->s3c_hsotg->phy);
-       clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+       if (dwc2->s3c_hsotg->clk)
+               clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
        return 0;
 }
-- 
1.7.9.5

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

Reply via email to