All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed
@ 2013-11-07 11:14 Valentine Barshak
  2013-11-07 13:06 ` Peter Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Valentine Barshak @ 2013-11-07 11:14 UTC (permalink / raw)
  To: linux-sh

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.

Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
---
 drivers/usb/core/hcd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index d939521..fd09ec6 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -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]. */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed
  2013-11-07 11:14 [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Valentine Barshak
@ 2013-11-07 13:06 ` Peter Chen
  2013-11-07 14:50 ` Valentine
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2013-11-07 13:06 UTC (permalink / raw)
  To: linux-sh


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

If the platform doesn't has phy driver, and with CONFIG_USB_PHY enabled, it
will have problem for above code.

Peter 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed
  2013-11-07 11:14 [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Valentine Barshak
  2013-11-07 13:06 ` Peter Chen
@ 2013-11-07 14:50 ` Valentine
  2013-11-07 15:18 ` Alan Stern
  2013-11-08  1:44 ` Peter Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Valentine @ 2013-11-07 14:50 UTC (permalink / raw)
  To: linux-sh

On 11/07/2013 05:06 PM, Peter Chen wrote:
>
>
>>
>> +#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
>> +
>
> If the platform doesn't has phy driver, and with CONFIG_USB_PHY enabled, it
> will have problem for above code.
>

It shouldn't have any problems since there's no phy bound to the HCD in this case.
Thus, usb_get_phy_dev returns -ENODEV and the HCD will be added as usual.

> Peter

Thanks,
Val.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed
  2013-11-07 11:14 [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Valentine Barshak
  2013-11-07 13:06 ` Peter Chen
  2013-11-07 14:50 ` Valentine
@ 2013-11-07 15:18 ` Alan Stern
  2013-11-08  1:44 ` Peter Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Alan Stern @ 2013-11-07 15:18 UTC (permalink / raw)
  To: linux-sh

On Thu, 7 Nov 2013, Valentine Barshak wrote:

> 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.
> 
> Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>

Acked-by: Alan Stern <stern@rowland.harvard.edu>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed
  2013-11-07 11:14 [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Valentine Barshak
                   ` (2 preceding siblings ...)
  2013-11-07 15:18 ` Alan Stern
@ 2013-11-08  1:44 ` Peter Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2013-11-08  1:44 UTC (permalink / raw)
  To: linux-sh


 
> >>
> >> +#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
> >> +
> >
> > If the platform doesn't has phy driver, and with CONFIG_USB_PHY enabled,
> it
> > will have problem for above code.
> >
> 
> It shouldn't have any problems since there's no phy bound to the HCD in
> this case.
> Thus, usb_get_phy_dev returns -ENODEV and the HCD will be added as usual.
> 
Yes, my fault. The retval will be override later.

Peter



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-08  1:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-07 11:14 [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Valentine Barshak
2013-11-07 13:06 ` Peter Chen
2013-11-07 14:50 ` Valentine
2013-11-07 15:18 ` Alan Stern
2013-11-08  1:44 ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.