* [PATCH 3/9] usb: hcd: Initialize USB phy if needed
@ 2013-11-20 17:38 Ulrich Hecht
2013-11-20 17:46 ` Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ulrich Hecht @ 2013-11-20 17:38 UTC (permalink / raw)
To: linux-sh
From: Valentine Barshak <valentine.barshak@cogentembedded.com>
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>
---
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.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/9] usb: hcd: Initialize USB phy if needed
2013-11-20 17:38 [PATCH 3/9] usb: hcd: Initialize USB phy if needed Ulrich Hecht
@ 2013-11-20 17:46 ` Fabio Estevam
2013-11-20 21:26 ` Valentine
2013-11-21 4:28 ` Simon Horman
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2013-11-20 17:46 UTC (permalink / raw)
To: linux-sh
On Wed, Nov 20, 2013 at 3:38 PM, Ulrich Hecht <ulrich.hecht@gmail.com> wrote:
> From: Valentine Barshak <valentine.barshak@cogentembedded.com>
>
> 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>
> ---
> 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);
Wouldn't it be better to use the following instead?
if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->(phy) {
Regards,
Fabio Estevam
> +
> + 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/9] usb: hcd: Initialize USB phy if needed
2013-11-20 17:38 [PATCH 3/9] usb: hcd: Initialize USB phy if needed Ulrich Hecht
2013-11-20 17:46 ` Fabio Estevam
@ 2013-11-20 21:26 ` Valentine
2013-11-21 4:28 ` Simon Horman
2 siblings, 0 replies; 4+ messages in thread
From: Valentine @ 2013-11-20 21:26 UTC (permalink / raw)
To: linux-sh
On 11/20/2013 09:46 PM, Fabio Estevam wrote:
> On Wed, Nov 20, 2013 at 3:38 PM, Ulrich Hecht <ulrich.hecht@gmail.com> wrote:
>> From: Valentine Barshak <valentine.barshak@cogentembedded.com>
>>
>> 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>
>> ---
>> 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);
>
> 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.
>
> Regards,
>
> Fabio Estevam
Thanks,
Val.
>
>> +
>> + 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 majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/9] usb: hcd: Initialize USB phy if needed
2013-11-20 17:38 [PATCH 3/9] usb: hcd: Initialize USB phy if needed Ulrich Hecht
2013-11-20 17:46 ` Fabio Estevam
2013-11-20 21:26 ` Valentine
@ 2013-11-21 4:28 ` Simon Horman
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2013-11-21 4:28 UTC (permalink / raw)
To: linux-sh
On Thu, Nov 21, 2013 at 01:26:19AM +0400, Valentine wrote:
> On 11/20/2013 09:46 PM, Fabio Estevam wrote:
> >On Wed, Nov 20, 2013 at 3:38 PM, Ulrich Hecht <ulrich.hecht@gmail.com> wrote:
> >>From: Valentine Barshak <valentine.barshak@cogentembedded.com>
> >>
> >>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>
> >>---
> >> 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);
> >
> >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.
The difference is that IS_ENABLED() is thought to be less ugly
than #ifdef. For this reason I agree with Fabio's comment.
>
> >
> >Regards,
> >
> >Fabio Estevam
>
> Thanks,
> Val.
>
> >
> >>+
> >>+ 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 majordomo@vger.kernel.org
> >>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-21 4:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 17:38 [PATCH 3/9] usb: hcd: Initialize USB phy if needed Ulrich Hecht
2013-11-20 17:46 ` Fabio Estevam
2013-11-20 21:26 ` Valentine
2013-11-21 4:28 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).