Re: RFC: Platform data for onboard USB assets

Arnd Bergmann
2011-03-11T15:22:17Z

On Friday 11 March 2011, Roger Quadros wrote:
> > There is no reason I can see that onboard USB assets should continue to
> > be treated differently to miss out on the same capability because they
> > are USB and not I2C, particularly as a permanently NULL platform_data
> > pointer is already sitting there in the usb_device's .dev already
> > exactly for this use.
>
> What do you want to set in platform data? the ethernet device name?
> Isn't that better done in user space using udev rules?

A udev rule would solve the problem at hand, but I'd consider that
an ugly workaround as well. The naming in the kernel is really
bogus -- any USB device that has a fixed address gets treated
as eth0, while others become usb0, with the same driver,
see the code fragment below.

A lot of things depend on ethernet device naming, which you
may consider to be broken, but it won't change any time soon.
Changing all of them to be named eth%d would of course break
other tools, so that is not an option either.

The most simple way to solve this particular problem is to
remove the check for "net->dev_addr [0] & 0x02", which only
has any effect on the smsc75xx and smsc95xx drivers, both of
which are for real ethernet devices, not point-to-point
USB links.

That would however still leave the problem of the missing
mac address, which is not good if you want to work with the
system using dhcp.

Arnd
---
strcpy (net->name, "usb%d");
// heuristic: "usb%d" for links we know are two-host,
// else "eth%d" when there's reasonable doubt. userspace
// can rename the link if it knows better.
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
(net->dev_addr [0] & 0x02) == 0)
strcpy (net->name, "eth%d");
/* WLAN devices should always be named "wlan%d" */
if ((dev->driver_info->flags & FLAG_WLAN) != 0)
strcpy(net->name, "wlan%d");
/* WWAN devices should always be named "wwan%d" */
if ((dev->driver_info->flags & FLAG_WWAN) != 0)
strcpy(net->name, "wwan%d");