usbnet: use eth%d name for known ethernet devices
authorArnd Bergmann <arnd.bergmann@linaro.org>
Sat, 2 Apr 2011 03:12:02 +0000 (20:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 2 Apr 2011 03:12:02 +0000 (20:12 -0700)
The documentation for the USB ethernet devices suggests that
only some devices are supposed to use usb0 as the network interface
name instead of eth0. The logic used there, and documented in
Kconfig for CDC is that eth0 will be used when the mac address
is a globally assigned one, but usb0 is used for the locally
managed range that is typically used on point-to-point links.

Unfortunately, this has caused a lot of pain on the smsc95xx
device that is used on the popular pandaboard without an
EEPROM to store the MAC address, which causes the driver to
call random_ether_address().

Obviously, there should be a proper MAC addressed assigned to
the device, and discussions are ongoing about how to solve
this, but this patch at least makes sure that the default
interface naming gets a little saner and matches what the
user can expect based on the documentation, including for
new devices.

The approach taken here is to flag whether a device might be a
point-to-point link with the new FLAG_POINTTOPOINT setting in
the usbnet driver_info. A driver can set both FLAG_POINTTOPOINT
and FLAG_ETHER if it is not sure (e.g. cdc_ether), or just one
of the two.  The usbnet framework only looks at the MAC address
for device naming if both flags are set, otherwise it trusts the
flag.

Signed-off-by: Arnd Bergmann <arnd.bergmann@linaro.org>
Tested-by: Andy Green <andy.green@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_eem.c
drivers/net/usb/cdc_ether.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/cdc_subset.c
drivers/net/usb/gl620a.c
drivers/net/usb/net1080.c
drivers/net/usb/plusb.c
drivers/net/usb/rndis_host.c
drivers/net/usb/usbnet.c
drivers/net/usb/zaurus.c
include/linux/usb/usbnet.h

index 5f3b97668e63c80ae37cb07dcd556d04a113c696..8f128541656d90317ef7355cb25b4cbc4795f197 100644 (file)
@@ -340,7 +340,7 @@ next:
 
 static const struct driver_info eem_info = {
        .description =  "CDC EEM Device",
-       .flags =        FLAG_ETHER,
+       .flags =        FLAG_ETHER | FLAG_POINTTOPOINT,
        .bind =         eem_bind,
        .rx_fixup =     eem_rx_fixup,
        .tx_fixup =     eem_tx_fixup,
index 51c259b69278356b3f3994f67603a8efc67c914c..341f7056a800ec2146c6187e3e9aca5ff6f7be5d 100644 (file)
@@ -452,7 +452,7 @@ static int cdc_manage_power(struct usbnet *dev, int on)
 
 static const struct driver_info        cdc_info = {
        .description =  "CDC Ethernet Device",
-       .flags =        FLAG_ETHER,
+       .flags =        FLAG_ETHER | FLAG_POINTTOPOINT,
        // .check_connect = cdc_check_connect,
        .bind =         usbnet_cdc_bind,
        .unbind =       usbnet_cdc_unbind,
index 7113168473cf43413ee1a011b1512dd74f9d1618..967371f04454205a1b147bddf27443a1e14f003a 100644 (file)
@@ -1237,7 +1237,7 @@ static int cdc_ncm_manage_power(struct usbnet *dev, int status)
 
 static const struct driver_info cdc_ncm_info = {
        .description = "CDC NCM",
-       .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET,
+       .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
        .check_connect = cdc_ncm_check_connect,
index ca39ace0b0eb7ba8a924ba724cbc1258ead98257..fc5f13d47ad9b7cec1bf30a0bee18efd81b6ae68 100644 (file)
@@ -89,6 +89,7 @@ static int always_connected (struct usbnet *dev)
 
 static const struct driver_info        ali_m5632_info = {
        .description =  "ALi M5632",
+       .flags       = FLAG_POINTTOPOINT,
 };
 
 #endif
@@ -110,6 +111,7 @@ static const struct driver_info     ali_m5632_info = {
 
 static const struct driver_info        an2720_info = {
        .description =  "AnchorChips/Cypress 2720",
+       .flags       = FLAG_POINTTOPOINT,
        // no reset available!
        // no check_connect available!
 
@@ -132,6 +134,7 @@ static const struct driver_info     an2720_info = {
 
 static const struct driver_info        belkin_info = {
        .description =  "Belkin, eTEK, or compatible",
+       .flags       = FLAG_POINTTOPOINT,
 };
 
 #endif /* CONFIG_USB_BELKIN */
@@ -157,6 +160,7 @@ static const struct driver_info     belkin_info = {
 static const struct driver_info        epson2888_info = {
        .description =  "Epson USB Device",
        .check_connect = always_connected,
+       .flags = FLAG_POINTTOPOINT,
 
        .in = 4, .out = 3,
 };
@@ -173,6 +177,7 @@ static const struct driver_info     epson2888_info = {
 #define HAVE_HARDWARE
 static const struct driver_info kc2190_info = {
        .description =  "KC Technology KC-190",
+       .flags = FLAG_POINTTOPOINT,
 };
 #endif /* CONFIG_USB_KC2190 */
 
@@ -200,16 +205,19 @@ static const struct driver_info kc2190_info = {
 static const struct driver_info        linuxdev_info = {
        .description =  "Linux Device",
        .check_connect = always_connected,
+       .flags = FLAG_POINTTOPOINT,
 };
 
 static const struct driver_info        yopy_info = {
        .description =  "Yopy",
        .check_connect = always_connected,
+       .flags = FLAG_POINTTOPOINT,
 };
 
 static const struct driver_info        blob_info = {
        .description =  "Boot Loader OBject",
        .check_connect = always_connected,
+       .flags = FLAG_POINTTOPOINT,
 };
 
 #endif /* CONFIG_USB_ARMLINUX */
index dcd57c37ef733322a894cfebcb3956aa2d4705c7..c4cfd1dea88149d56fb1315155d10a6461cfeb9d 100644 (file)
@@ -193,7 +193,7 @@ static int genelink_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static const struct driver_info        genelink_info = {
        .description =  "Genesys GeneLink",
-       .flags =        FLAG_FRAMING_GL | FLAG_NO_SETINT,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_GL | FLAG_NO_SETINT,
        .bind =         genelink_bind,
        .rx_fixup =     genelink_rx_fixup,
        .tx_fixup =     genelink_tx_fixup,
index ba72a7281cb0d4387e6549c3c31e6862704c3c87..01db4602a39edbc75dadb39dec0d6a4bfb9ad147 100644 (file)
@@ -560,7 +560,7 @@ static int net1080_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static const struct driver_info        net1080_info = {
        .description =  "NetChip TurboCONNECT",
-       .flags =        FLAG_FRAMING_NC,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_NC,
        .bind =         net1080_bind,
        .reset =        net1080_reset,
        .check_connect = net1080_check_connect,
index 08ad269f6b4e2619eefeb4da7b1f0c88bdd352c3..823c53751307230af2fc21c99abcefefea4aa2ca 100644 (file)
@@ -96,7 +96,7 @@ static int pl_reset(struct usbnet *dev)
 
 static const struct driver_info        prolific_info = {
        .description =  "Prolific PL-2301/PL-2302",
-       .flags =        FLAG_NO_SETINT,
+       .flags =        FLAG_POINTTOPOINT | FLAG_NO_SETINT,
                /* some PL-2302 versions seem to fail usb_set_interface() */
        .reset =        pl_reset,
 };
index dd8a4adf48cadf3d1c85507dc9c71c9d9c316004..5994a25c56ac0e4967db3aaffed28b646f2b8974 100644 (file)
@@ -573,7 +573,7 @@ EXPORT_SYMBOL_GPL(rndis_tx_fixup);
 
 static const struct driver_info        rndis_info = {
        .description =  "RNDIS device",
-       .flags =        FLAG_ETHER | FLAG_FRAMING_RN | FLAG_NO_SETINT,
+       .flags =        FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
        .bind =         rndis_bind,
        .unbind =       rndis_unbind,
        .status =       rndis_status,
index cf58b7682565ea0966f96393cd5efbb213587eb8..069c1cf0fdf73675dbb865b27ee4d673bd773840 100644 (file)
@@ -1380,7 +1380,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
                // 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)
+                   ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 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)
index 3eb0b167b5b46ac278e5b92b3aa7835d57344439..241756e0e86f03e86a1b368408c761389967d8f8 100644 (file)
@@ -102,7 +102,7 @@ static int always_connected (struct usbnet *dev)
 
 static const struct driver_info        zaurus_sl5x00_info = {
        .description =  "Sharp Zaurus SL-5x00",
-       .flags =        FLAG_FRAMING_Z,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
        .check_connect = always_connected,
        .bind =         zaurus_bind,
        .unbind =       usbnet_cdc_unbind,
@@ -112,7 +112,7 @@ static const struct driver_info     zaurus_sl5x00_info = {
 
 static const struct driver_info        zaurus_pxa_info = {
        .description =  "Sharp Zaurus, PXA-2xx based",
-       .flags =        FLAG_FRAMING_Z,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
        .check_connect = always_connected,
        .bind =         zaurus_bind,
        .unbind =       usbnet_cdc_unbind,
@@ -122,7 +122,7 @@ static const struct driver_info     zaurus_pxa_info = {
 
 static const struct driver_info        olympus_mxl_info = {
        .description =  "Olympus R1000",
-       .flags =        FLAG_FRAMING_Z,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
        .check_connect = always_connected,
        .bind =         zaurus_bind,
        .unbind =       usbnet_cdc_unbind,
@@ -258,7 +258,7 @@ bad_desc:
 
 static const struct driver_info        bogus_mdlm_info = {
        .description =  "pseudo-MDLM (BLAN) device",
-       .flags =        FLAG_FRAMING_Z,
+       .flags =        FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
        .check_connect = always_connected,
        .tx_fixup =     zaurus_tx_fixup,
        .bind =         blan_mdlm_bind,
index 201f2228f731c7e1ccd8d84a60c01647ee3bee11..3c7329b8ea0e466a11fef6a176570138de116424 100644 (file)
@@ -97,6 +97,8 @@ struct driver_info {
 
 #define FLAG_LINK_INTR 0x0800          /* updates link (carrier) status */
 
+#define FLAG_POINTTOPOINT 0x1000       /* possibly use "usb%d" names */
+
 /*
  * Indicates to usbnet, that USB driver accumulates multiple IP packets.
  * Affects statistic (counters) and short packet handling.