[U-Boot] [PATCH v3] usb: new board-specific USB init interface

Marek Vasut
2013-09-05T17:51:56Z

Dear Mateusz Zalega,

> On 09/05/13 17:50, Marek Vasut wrote:
> >> v3 changes:
> >> - added 'index' argument to perform selective port initialization
> >
> > OK, a few general ideas again:
> >
> > Why not wrap board_usb_init() and board_usb_init_fail() into single call.
> > You now pass some flags to board_usb_init() already, so just add another
> > for the fail case. How does it sound to you?
>
> Like overengineering. It would lead to "board_usb_init(USB_INIT_ALL,
> USB_INIT_DEVICE, USB_CLEANUP)" calls, which are not very readable.

This is not what I mean, see this:

int board_usb_init(int index, enum board_usb_init_type init)

Add a new "init" type (or maybe change the init field to be flags) that will say
"OK, do a fail init" ?

> > Moreover, the 'int index' should likely be unsigned int and the special
> > value to init all controllers at once should probably then be 0xffffffff
>
> Despite our greatest ambitions, I don't think we're likely to use more
> than 2^31-1 USB controllers at a time. Besides, negative values look
> better both in code and debugger session.

Thinking of it further, instead of using negative value here, like I mentioned
above, why not make the "board_usb_init_type" into a field of flags , then add
flag to init all controllers at once ?

Best regards,
Marek Vasut