Skip to contentSkip to conversation

usb: hcd: Initialize USB phy if needed

PATCH In review Ulrich Hecht 4 participants 4 messages Nov 20, 2013 – Nov 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/9 usb: hcd: Initialize USB phy if needed

From: Valentine Barshak <[email protected]>

This adds external USB phy support to USB HCD driver that allows to find and initialize external USB phy, bound to the HCD, when the HCD is added.
The usb_add_hcd function returns -EPROBE_DEFER if the USB phy, bound to the HCD, is not ready.
If no USB phy is bound, the HCD is initialized as usual.

---
 drivers/usb/core/hcd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/usb/core/hcd.c +20 -0
index d939521..fd09ec6 100644
@@ -2597,6 +2597,26 @@ int usb_add_hcd(struct usb_hcd *hcd,
 	int retval;
 	struct usb_device *rhdev;
 
+#ifdef CONFIG_USB_PHY
+	if (!hcd->phy) {
+		struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
+
+		if (IS_ERR(phy)) {
+			retval = PTR_ERR(phy);
+			if (retval = -EPROBE_DEFER)
+				return retval;
+		} else {
+			retval = usb_phy_init(phy);
+			if (retval) {
+				usb_put_phy(phy);
+				return retval;
+			}
+			hcd->phy = phy;
+			hcd->remove_phy = 1;
+		}
+	}
+#endif
+
 	dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
 
 	/* Keep old behaviour if authorized_default is not in [0, 1]. */
Signature · 1 line
1.8.4
#1 lore raw
Quoted 20 lines · Ulrich Hecht

From: Valentine Barshak <[email protected]>

This adds external USB phy support to USB HCD driver that allows to find and initialize external USB phy, bound to the HCD, when the HCD is added.
The usb_add_hcd function returns -EPROBE_DEFER if the USB phy, bound to the HCD, is not ready.
If no USB phy is bound, the HCD is initialized as usual.

---
 drivers/usb/core/hcd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/usb/core/hcd.c +0 -0
index d939521..fd09ec6 100644

drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2602

Quoted 6 lines
drivers/usb/core/hcd.c +3 -0
@@ -2597,6 +2597,26 @@ int usb_add_hcd(struct usb_hcd *hcd,
        int retval;
        struct usb_device *rhdev;
 
+#ifdef CONFIG_USB_PHY
+       if (!hcd->phy) {
+               struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);

Wouldn't it be better to use the following instead?

          if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->(phy) {

Regards,

Fabio Estevam

Quoted 27 lines
drivers/usb/core/hcd.c +17 -1
+
+               if (IS_ERR(phy)) {
+                       retval = PTR_ERR(phy);
+                       if (retval = -EPROBE_DEFER)
+                               return retval;
+               } else {
+                       retval = usb_phy_init(phy);
+                       if (retval) {
+                               usb_put_phy(phy);
+                               return retval;
+                       }
+                       hcd->phy = phy;
+                       hcd->remove_phy = 1;
+               }
+       }
+#endif
+
        dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
 
        /* Keep old behaviour if authorized_default is not in [0, 1]. */
--

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

#2 lore raw
In reply to Ulrich Hecht
Quoted 24 lines · Fabio Estevam
Quoted 23 lines · Ulrich Hecht

From: Valentine Barshak <[email protected]>

This adds external USB phy support to USB HCD driver that allows to find and initialize external USB phy, bound to the HCD, when the HCD is added.
The usb_add_hcd function returns -EPROBE_DEFER if the USB phy, bound to the HCD, is not ready.
If no USB phy is bound, the HCD is initialized as usual.

---
  drivers/usb/core/hcd.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/usb/core/hcd.c +0 -0
index d939521..fd09ec6 100644
@@ -2597,6 +2597,26 @@ int usb_add_hcd(struct usb_hcd *hcd,
         int retval;
         struct usb_device *rhdev;
 
Quoted 7 lines

drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2602

Quoted 3 lines
drivers/usb/core/hcd.c +3 -0
+#ifdef CONFIG_USB_PHY
+       if (!hcd->phy) {
+               struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);

Wouldn't it be better to use the following instead?

           if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->(phy) {

Since USB_PHY is a bool I don't see much of a difference.

Quoted 4 lines

Regards,

Fabio Estevam

Thanks,
Val.

Quoted 28 lines
Quoted 28 lines
drivers/usb/core/hcd.c +17 -1
+
+               if (IS_ERR(phy)) {
+                       retval = PTR_ERR(phy);
+                       if (retval = -EPROBE_DEFER)
+                               return retval;
+               } else {
+                       retval = usb_phy_init(phy);
+                       if (retval) {
+                               usb_put_phy(phy);
+                               return retval;
+                       }
+                       hcd->phy = phy;
+                       hcd->remove_phy = 1;
+               }
+       }
+#endif
+
         dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
 
         /* Keep old behaviour if authorized_default is not in [0, 1]. */
--

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

#3 lore raw
In reply to Ulrich Hecht
Quoted 31 lines · Valentine
Quoted 30 lines · Fabio Estevam
Quoted 20 lines · Ulrich Hecht

From: Valentine Barshak <[email protected]>

This adds external USB phy support to USB HCD driver that allows to find and initialize external USB phy, bound to the HCD, when the HCD is added.
The usb_add_hcd function returns -EPROBE_DEFER if the USB phy, bound to the HCD, is not ready.
If no USB phy is bound, the HCD is initialized as usual.

---
 drivers/usb/core/hcd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/usb/core/hcd.c +0 -0
index d939521..fd09ec6 100644

drivers/usb/core/hcd.c int usb_add_hcd(struct usb_hcd *hcd, · line 2602

Quoted 6 lines
drivers/usb/core/hcd.c +3 -0
@@ -2597,6 +2597,26 @@ int usb_add_hcd(struct usb_hcd *hcd,
        int retval;
        struct usb_device *rhdev;
 
+#ifdef CONFIG_USB_PHY
+       if (!hcd->phy) {
+               struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);

Wouldn't it be better to use the following instead?

Quoted 3 lines
Quoted 1 line
          if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->(phy) {

Since USB_PHY is a bool I don't see much of a difference.

The difference is that IS_ENABLED() is thought to be less ugly than #ifdef. For this reason I agree with Fabio's comment.

Quoted 38 lines
Quoted 5 lines

Regards,

Fabio Estevam

Thanks,
Val.

Quoted 28 lines
Quoted 28 lines
drivers/usb/core/hcd.c +17 -1
+
+               if (IS_ERR(phy)) {
+                       retval = PTR_ERR(phy);
+                       if (retval = -EPROBE_DEFER)
+                               return retval;
+               } else {
+                       retval = usb_phy_init(phy);
+                       if (retval) {
+                               usb_put_phy(phy);
+                               return retval;
+                       }
+                       hcd->phy = phy;
+                       hcd->remove_phy = 1;
+               }
+       }
+#endif
+
        dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
 
        /* Keep old behaviour if authorized_default is not in [0, 1]. */
--

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