Commit 0331c3a6 authored by Kevin Cernekee's avatar Kevin Cernekee Committed by Ben Hutchings

usb: gadget: Fix g_ether interface link status

commit 31bde1ce upstream.

A "usb0" interface that has never been connected to a host has an unknown
operstate, and therefore the IFF_RUNNING flag is (incorrectly) asserted
when queried by ifconfig, ifplugd, etc.  This is a result of calling
netif_carrier_off() too early in the probe function; it should be called
after register_netdev().

Similar problems have been fixed in many other drivers, e.g.:

    e826eafa (bonding: Call netif_carrier_off after register_netdevice)
    0d672e9f (drivers/net: Call netif_carrier_off at the end of the probe)
    6a3c869a (cxgb4: fix reported state of interfaces without link)

Fix is to move netif_carrier_off() to the end of the function.
Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 8d54ec42
......@@ -796,12 +796,6 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
SET_ETHTOOL_OPS(net, &ops);
/* two kinds of host-initiated state changes:
* - iff DATA transfer is active, carrier is "on"
* - tx queueing enabled if open *and* carrier is "on"
*/
netif_carrier_off(net);
dev->gadget = g;
SET_NETDEV_DEV(net, &g->dev);
SET_NETDEV_DEVTYPE(net, &gadget_type);
......@@ -815,6 +809,12 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
the_dev = dev;
/* two kinds of host-initiated state changes:
* - iff DATA transfer is active, carrier is "on"
* - tx queueing enabled if open *and* carrier is "on"
*/
netif_carrier_off(net);
}
return status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment