diff mbox

[1/3] arm: omap: musb: proper error checking

Message ID 1274262018-32631-1-git-send-email-felipe.balbi@nokia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi May 19, 2010, 9:40 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 116548d..085e22e 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -60,23 +60,34 @@  static void __init usb_musb_pm_init(void)
 
 	dev_set_name(dev, "musb_hdrc");
 	otg_clk = clk_get(dev, "ick");
+	if (IS_ERR(otg_clk)) {
+		printk(KERN_WARNING "%s: Unable to get clock for MUSB.\n",
+				__func__);
+		goto out0;
+	}
 
-	if (otg_clk && clk_enable(otg_clk)) {
+	if (clk_enable(otg_clk)) {
 		printk(KERN_WARNING
 			"%s: Unable to enable clocks for MUSB, "
 			"cannot reset.\n",  __func__);
-	} else {
-		/* Reset OTG controller. After reset, it will be in
-		 * force-idle, force-standby mode. */
-		__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
-
-		while (!(OTG_SYSS_RESETDONE &
-					__raw_readl(otg_base + OTG_SYSSTATUS)))
-			cpu_relax();
+		goto out1;
 	}
 
-	if (otg_clk)
-		clk_disable(otg_clk);
+	/* Reset OTG controller. After reset, it will be in
+	 * force-idle, force-standby mode. */
+	__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
+
+	while (!(OTG_SYSS_RESETDONE &
+				__raw_readl(otg_base + OTG_SYSSTATUS)))
+		cpu_relax();
+
+	clk_disable(otg_clk);
+
+out1:
+	clk_put(otg_clk);
+
+out0:
+	iounmap(otg_base);
 }
 
 void usb_musb_disable_autoidle(void)