diff mbox series

[U-Boot,v1,1/2] dm: usb: udc: Use SEQ_ALIAS to index the USB gadget ports

Message ID 1544892208-28852-2-git-send-email-jjhiblot@ti.com
State Accepted
Commit 801f1fa44275e274e33bdfc7fb76535cc6118d61
Delegated to: Lukasz Majewski
Headers show
Series Fix USB port indexes for USB gadget commands | expand

Commit Message

Jean-Jacques Hiblot Dec. 15, 2018, 4:43 p.m. UTC
dfu, fastbot and other usb gadget commands take the USB port index as a
parameter. Currently this index is assigned in the order of the driver
bindings.
Changing this behavior using the SEQ_ALIAS feature. This option assign to
the device a SEQ number based on its alias (if it exists)

To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the existing
naming convention: use "usb" for the name of the gadget UCLASS_DRIVER
(same as for the UCLASS_USB).

If no alias is provided, then the index falls back to the order in which
the bindings took place.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reported-by: Sam Protsenko <semen.protsenko@linaro.org>
---

 drivers/usb/gadget/udc/udc-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Marek Vasut Dec. 15, 2018, 6:36 p.m. UTC | #1
On 12/15/2018 05:43 PM, Jean-Jacques Hiblot wrote:
> dfu, fastbot and other usb gadget commands take the USB port index as a

fastboot.

Looks good to me, I expect Lukasz to pick it, test it and send me a PR.

> parameter. Currently this index is assigned in the order of the driver
> bindings.
> Changing this behavior using the SEQ_ALIAS feature. This option assign to
> the device a SEQ number based on its alias (if it exists)
> 
> To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the existing
> naming convention: use "usb" for the name of the gadget UCLASS_DRIVER
> (same as for the UCLASS_USB).
> 
> If no alias is provided, then the index falls back to the order in which
> the bindings took place.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> Reported-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
> 
>  drivers/usb/gadget/udc/udc-uclass.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
> index 0620518..e9f8f5f 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -20,7 +20,7 @@ int usb_gadget_initialize(int index)
>  		return -EINVAL;
>  	if (dev_array[index])
>  		return 0;
> -	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
> +	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
>  	if (!dev || ret) {
>  		pr_err("No USB device found\n");
>  		return -ENODEV;
> @@ -54,5 +54,6 @@ int usb_gadget_handle_interrupts(int index)
>  
>  UCLASS_DRIVER(usb_gadget_generic) = {
>  	.id		= UCLASS_USB_GADGET_GENERIC,
> -	.name		= "usb_gadget_generic",
> +	.name		= "usb",
> +	.flags		= DM_UC_FLAG_SEQ_ALIAS,
>  };
>
Lukasz Majewski Dec. 16, 2018, 8:47 p.m. UTC | #2
Hi Marek, Jean-Jacques,

> On 12/15/2018 05:43 PM, Jean-Jacques Hiblot wrote:
> > dfu, fastbot and other usb gadget commands take the USB port index
> > as a  
> 
> fastboot.
> 
> Looks good to me, I expect Lukasz to pick it, test it and send me a
> PR.
> 
> > parameter. Currently this index is assigned in the order of the
> > driver bindings.
> > Changing this behavior using the SEQ_ALIAS feature. This option
> > assign to the device a SEQ number based on its alias (if it exists)
> > 
> > To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the
> > existing naming convention: use "usb" for the name of the gadget
> > UCLASS_DRIVER (same as for the UCLASS_USB).

I must admit that this change fixes a long standing problem with the
usb number assignment.

Great job. I will test and send it in a few days time.

> > 
> > If no alias is provided, then the index falls back to the order in
> > which the bindings took place.
> > 
> > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> > Reported-by: Sam Protsenko <semen.protsenko@linaro.org>
> > ---
> > 
> >  drivers/usb/gadget/udc/udc-uclass.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/udc-uclass.c
> > b/drivers/usb/gadget/udc/udc-uclass.c index 0620518..e9f8f5f 100644
> > --- a/drivers/usb/gadget/udc/udc-uclass.c
> > +++ b/drivers/usb/gadget/udc/udc-uclass.c
> > @@ -20,7 +20,7 @@ int usb_gadget_initialize(int index)
> >  		return -EINVAL;
> >  	if (dev_array[index])
> >  		return 0;
> > -	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index,
> > &dev);
> > +	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC,
> > index, &dev); if (!dev || ret) {
> >  		pr_err("No USB device found\n");
> >  		return -ENODEV;
> > @@ -54,5 +54,6 @@ int usb_gadget_handle_interrupts(int index)
> >  
> >  UCLASS_DRIVER(usb_gadget_generic) = {
> >  	.id		= UCLASS_USB_GADGET_GENERIC,
> > -	.name		= "usb_gadget_generic",
> > +	.name		= "usb",
> > +	.flags		= DM_UC_FLAG_SEQ_ALIAS,
> >  };
> >   
> 
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Sam Protsenko Jan. 3, 2019, 3:47 p.m. UTC | #3
Tested on BeagleBoard X15, works fine. Thanks, Jean-Jacques!

Lukasz, is there any way this series can make it to v2019.01 release?
Like to see it there, for stability/consistence reasons.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>

Thanks!

On Sun, Dec 16, 2018 at 10:47 PM Lukasz Majewski <lukma@denx.de> wrote:
>
> Hi Marek, Jean-Jacques,
>
> > On 12/15/2018 05:43 PM, Jean-Jacques Hiblot wrote:
> > > dfu, fastbot and other usb gadget commands take the USB port index
> > > as a
> >
> > fastboot.
> >
> > Looks good to me, I expect Lukasz to pick it, test it and send me a
> > PR.
> >
> > > parameter. Currently this index is assigned in the order of the
> > > driver bindings.
> > > Changing this behavior using the SEQ_ALIAS feature. This option
> > > assign to the device a SEQ number based on its alias (if it exists)
> > >
> > > To use it we must set the DM_UC_FLAG_SEQ_ALIAS flag and follow the
> > > existing naming convention: use "usb" for the name of the gadget
> > > UCLASS_DRIVER (same as for the UCLASS_USB).
>
> I must admit that this change fixes a long standing problem with the
> usb number assignment.
>
> Great job. I will test and send it in a few days time.
>
> > >
> > > If no alias is provided, then the index falls back to the order in
> > > which the bindings took place.
> > >
> > > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> > > Reported-by: Sam Protsenko <semen.protsenko@linaro.org>
> > > ---
> > >
> > >  drivers/usb/gadget/udc/udc-uclass.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/usb/gadget/udc/udc-uclass.c
> > > b/drivers/usb/gadget/udc/udc-uclass.c index 0620518..e9f8f5f 100644
> > > --- a/drivers/usb/gadget/udc/udc-uclass.c
> > > +++ b/drivers/usb/gadget/udc/udc-uclass.c
> > > @@ -20,7 +20,7 @@ int usb_gadget_initialize(int index)
> > >             return -EINVAL;
> > >     if (dev_array[index])
> > >             return 0;
> > > -   ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index,
> > > &dev);
> > > +   ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC,
> > > index, &dev); if (!dev || ret) {
> > >             pr_err("No USB device found\n");
> > >             return -ENODEV;
> > > @@ -54,5 +54,6 @@ int usb_gadget_handle_interrupts(int index)
> > >
> > >  UCLASS_DRIVER(usb_gadget_generic) = {
> > >     .id             = UCLASS_USB_GADGET_GENERIC,
> > > -   .name           = "usb_gadget_generic",
> > > +   .name           = "usb",
> > > +   .flags          = DM_UC_FLAG_SEQ_ALIAS,
> > >  };
> > >
> >
> >
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
index 0620518..e9f8f5f 100644
--- a/drivers/usb/gadget/udc/udc-uclass.c
+++ b/drivers/usb/gadget/udc/udc-uclass.c
@@ -20,7 +20,7 @@  int usb_gadget_initialize(int index)
 		return -EINVAL;
 	if (dev_array[index])
 		return 0;
-	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
+	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
 	if (!dev || ret) {
 		pr_err("No USB device found\n");
 		return -ENODEV;
@@ -54,5 +54,6 @@  int usb_gadget_handle_interrupts(int index)
 
 UCLASS_DRIVER(usb_gadget_generic) = {
 	.id		= UCLASS_USB_GADGET_GENERIC,
-	.name		= "usb_gadget_generic",
+	.name		= "usb",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
 };