Skip to contentSkip to conversation

usb: otg: OMAP4430: Fix omap4430_phy_init function

PATCH Superseded Hema HK 4 participants 6 messages Mar 24, 2011 – Mar 28, 2011 3 messages not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Hema HK

author
#0 lore raw

PATCH 1/2 usb: otg: OMAP4430: Fix omap4430_phy_init function

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

---
 arch/arm/mach-omap2/omap_phy_internal.c |   44 ++++++++++++++++--------------
 1 files changed, 23 insertions(+), 21 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +23 -21
index e2e605f..a959e2f 100644
@@ -50,34 +50,36 @@ int omap4430_phy_init(struct device *dev)
 {
 	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
 	if (!ctrl_base) {
-		dev_err(dev, "control module ioremap failed\n");
+		printk(KERN_ERR "control module ioremap failed\n");
 		return -ENOMEM;
 	}
 	/* Power down the phy */
 	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
 
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
+	if (dev) {
+		phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
+		if (IS_ERR(phyclk)) {
+			dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
+			iounmap(ctrl_base);
+			return PTR_ERR(phyclk);
+		}
 
-	clk48m = clk_get(dev, "ocp2scp_usb_phy_phy_48m");
-	if (IS_ERR(clk48m)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_phy_48m\n");
-		clk_put(phyclk);
-		iounmap(ctrl_base);
-		return PTR_ERR(clk48m);
-	}
+		clk48m = clk_get(dev, "ocp2scp_usb_phy_phy_48m");
+		if (IS_ERR(clk48m)) {
+			dev_err(dev, "cannot clk_get ocp2scp_usb_phy_phy_48m\n");
+			clk_put(phyclk);
+			iounmap(ctrl_base);
+			return PTR_ERR(clk48m);
+		}
 
-	clk32k = clk_get(dev, "usb_phy_cm_clk32k");
-	if (IS_ERR(clk32k)) {
-		dev_err(dev, "cannot clk_get usb_phy_cm_clk32k\n");
-		clk_put(phyclk);
-		clk_put(clk48m);
-		iounmap(ctrl_base);
-		return PTR_ERR(clk32k);
+		clk32k = clk_get(dev, "usb_phy_cm_clk32k");
+		if (IS_ERR(clk32k)) {
+			dev_err(dev, "cannot clk_get usb_phy_cm_clk32k\n");
+			clk_put(phyclk);
+			clk_put(clk48m);
+			iounmap(ctrl_base);
+			return PTR_ERR(clk32k);
+		}
 	}
 	return 0;
 }
Signature · 6 lines
1.7.0.4

--
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
#1 lore raw
Quoted 14 lines · Hema HK

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

---
 arch/arm/mach-omap2/omap_phy_internal.c |   44 ++++++++++++++++--------------
 1 files changed, 23 insertions(+), 21 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +0 -0
index e2e605f..a959e2f 100644

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 53

Quoted 5 lines
arch/arm/mach-omap2/omap_phy_internal.c +1 -1
@@ -50,34 +50,36 @@ int omap4430_phy_init(struct device *dev)
 {
 	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
 	if (!ctrl_base) {
-		dev_err(dev, "control module ioremap failed\n");
+		printk(KERN_ERR "control module ioremap failed\n");

use pr_err()

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 59

Quoted 12 lines
arch/arm/mach-omap2/omap_phy_internal.c +1 -6
 		return -ENOMEM;
 	}
 	/* Power down the phy */
 	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
 
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
+	if (dev) {

you can avoid this nesting level:

if (!dev)

	return;
Signature · 1 line
balbi
#3 lore raw
In reply to a message not in the archive
Quoted 21 lines

-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Thursday, March 24, 2011 4:38 PM
To: Hema HK
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/2] usb: otg: OMAP4430: Fix
omap4430_phy_init function

Quoted 7 lines · Hema HK

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

---
 arch/arm/mach-omap2/omap_phy_internal.c |   44

++++++++++++++++--------------

Review

Quoted 3 lines
 1 files changed, 23 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-omap2/omap_phy_internal.c

Quoted 11 lines

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 53

Quoted 9 lines

index e2e605f..a959e2f 100644

arch/arm/mach-omap2/omap_phy_internal.c +1 -1
@@ -50,34 +50,36 @@ int omap4430_phy_init(struct device *dev)
 {
 	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
 	if (!ctrl_base) {
-		dev_err(dev, "control module ioremap failed\n");
+		printk(KERN_ERR "control module ioremap failed\n");

use pr_err()

OK.

Quoted 16 lines

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 59

Quoted 13 lines
arch/arm/mach-omap2/omap_phy_internal.c +1 -6
 		return -ENOMEM;
 	}
 	/* Power down the phy */
 	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
 
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
+	if (dev) {

you can avoid this nesting level:

Quoted 2 lines

if (!dev)

	return;

:-) Yes.

Regards,
Hema

Quoted 4 lines

--
balbi

--
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

#4 lore raw
In reply to Hema HK

Hello.

Quoted 14 lines · Hema HK

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

---
  arch/arm/mach-omap2/omap_phy_internal.c |   44 ++++++++++++++++--------------
  1 files changed, 23 insertions(+), 21 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +0 -0
index e2e605f..a959e2f 100644

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 53

Quoted 5 lines
arch/arm/mach-omap2/omap_phy_internal.c +1 -1
@@ -50,34 +50,36 @@ int omap4430_phy_init(struct device *dev)
  {
  	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
  	if (!ctrl_base) {
-		dev_err(dev, "control module ioremap failed\n");
+		printk(KERN_ERR "control module ioremap failed\n");

Use pr_err().

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 60

Quoted 13 lines
arch/arm/mach-omap2/omap_phy_internal.c +2 -6
  		return -ENOMEM;
  	}
  	/* Power down the phy */
  	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
 
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
+	if (dev) {
+		phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");

Couldn't clk_get() be called with NULL device ptr?

WBR, Sergei

#6 lore raw
In reply to a message not in the archive

Hi,

Quoted 24 lines

-----Original Message-----
From: Sergei Shtylyov [mailto:[email protected]]
Sent: Thursday, March 24, 2011 6:48 PM
To: Hema HK
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/2] usb: otg: OMAP4430: Fix
omap4430_phy_init function

Hello.

Quoted 7 lines · Hema HK

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

---
  arch/arm/mach-omap2/omap_phy_internal.c |   44

++++++++++++++++--------------

Review

Quoted 3 lines
  1 files changed, 23 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-omap2/omap_phy_internal.c

Quoted 11 lines

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 53

Quoted 9 lines

index e2e605f..a959e2f 100644

arch/arm/mach-omap2/omap_phy_internal.c +1 -1
@@ -50,34 +50,36 @@ int omap4430_phy_init(struct device *dev)
  {
  	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
  	if (!ctrl_base) {
-		dev_err(dev, "control module ioremap failed\n");
+		printk(KERN_ERR "control module ioremap failed\n");
   Use pr_err().

This is fixed in the next version of the patch submitted yesterday.

Quoted 7 lines
Quoted 7 lines
arch/arm/mach-omap2/omap_phy_internal.c +0 -1
  		return -ENOMEM;
  	}
  	/* Power down the phy */
  	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-	phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");
 
Quoted 9 lines

arch/arm/mach-omap2/omap_phy_internal.c int omap4430_phy_init(struct device *dev) · line 60

Quoted 7 lines
arch/arm/mach-omap2/omap_phy_internal.c +2 -5
-	if (IS_ERR(phyclk)) {
-		dev_err(dev, "cannot clk_get ocp2scp_usb_phy_ick\n");
-		iounmap(ctrl_base);
-		return PTR_ERR(phyclk);
-	}
+	if (dev) {
+		phyclk = clk_get(dev, "ocp2scp_usb_phy_ick");

Couldn't clk_get() be called with NULL device ptr?

Can be called with NULL pointer, but there will be issue with dev_err. And moreover, when there is no device built, there is no point in getting the clocks.

This function is called with NULL dev pointer only when there is no device built but has to powerdown the PHY.

Regards,
Hema

Quoted 3 lines

WBR, Sergei

--
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

#8 lore raw
In reply to a message not in the archive
Quoted 3 lines · Hema HK

omap4430_phy_init() function can be called with no device pointer to powerdown the UTMI PHY during board init when USB is disabled. Fix the function accordingly.

I don't think this is the case any longer, see merge commit 0df0914d414a504b975f3cc66ace0c16ef55b7f3.

Tony
--
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