[U-Boot] [PATCH] usb_ether: register usb ethernet gadget at each eth init

Lei Wen adrian.wenl at gmail.com
Sat Nov 27 15:21:48 CET 2010


Hi Vitaly,

On Sat, Nov 27, 2010 at 2:23 AM, Vitaly Kuzmichev <vkuzmichev at mvista.com> wrote:
> Hi Lei,
>
> Lei Wen wrote:
>> Since the ether may not be the only one usb gadget would be used
>> in the uboot, it is neccessary to do the register each time the
>> eth begin to work to make usb gadget driver less confussed when
>> we want to use two different usb gadget at the same time.
>> [...]
>> @@ -1788,6 +1788,8 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
>>               error("received NULL ptr");
>>               goto fail;
>>       }
>> +     if (usb_gadget_register_driver(&eth_driver) < 0)
>> +             goto fail;
>
> You probably need then at least to remove usb_gadget_register_driver
> call from usb_eth_initialize. And add usb_gadget_unregister_driver in
> usb_eth_halt.

I am afraid that remove usb_gadget_register_driver call from usb_eth_initialize
is not possible. For tftp as example, it would call eth_halt before
the eth_init.
If we do the remove behavior, the gadget still not valid yet in the
first eth_halt call
which would cause the uboot becomes halt.

> For example, my UDC driver returns EBUSY if another gadget driver tries
> to register itself. (Yes, I do not want to have more than 1 gadget).
> With your patch the gadget driver will fail each time when initializing.
> Anyway if I "fix" my UDC driver some day the Ether gadget will try to
> register itself twice (and more times later). So I will have to protect
> it against this bad behavior.

Two gadget example may comes from what I am using now.
I am current attempting to make the tftp and fastboot cowork togetther.
Since fastboot is a cool tool, I think people may want it beside they
still use the tftp.
Would that be enough convincing?:)

I think the gadget driver should adopt like this to allow two gadget coexist.
And from gadget driver's review, the switch from one gadget to another
is easy, just
register it to another should be enough. Does it really need to return EBUSY?

Best regards,
Lei


More information about the U-Boot mailing list