Merge git://git.infradead.org/mtd-2.6
[safe/jmp/linux-2.6] / drivers / usb / gadget / u_ether.c
index 3791e62..016f63b 100644 (file)
@@ -52,7 +52,7 @@
  * this single "physical" link to be used by multiple virtual links.)
  */
 
-#define DRIVER_VERSION "29-May-2008"
+#define UETH__VERSION  "29-May-2008"
 
 struct eth_dev {
        /* lock is held while accessing port_usb
@@ -146,7 +146,7 @@ static inline int qlen(struct usb_gadget *gadget)
 
 /* NETWORK DRIVER HOOKUP (to the layer above this driver) */
 
-static int eth_change_mtu(struct net_device *net, int new_mtu)
+static int ueth_change_mtu(struct net_device *net, int new_mtu)
 {
        struct eth_dev  *dev = netdev_priv(net);
        unsigned long   flags;
@@ -170,17 +170,11 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
        struct eth_dev  *dev = netdev_priv(net);
 
        strlcpy(p->driver, "g_ether", sizeof p->driver);
-       strlcpy(p->version, DRIVER_VERSION, sizeof p->version);
+       strlcpy(p->version, UETH__VERSION, sizeof p->version);
        strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version);
        strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info);
 }
 
-static u32 eth_get_link(struct net_device *net)
-{
-       struct eth_dev  *dev = netdev_priv(net);
-       return dev->gadget->speed != USB_SPEED_UNKNOWN;
-}
-
 /* REVISIT can also support:
  *   - WOL (by tracking suspends and issuing remote wakeup)
  *   - msglevel (implies updated messaging)
@@ -189,7 +183,7 @@ static u32 eth_get_link(struct net_device *net)
 
 static struct ethtool_ops ops = {
        .get_drvinfo = eth_get_drvinfo,
-       .get_link = eth_get_link
+       .get_link = ethtool_op_get_link,
 };
 
 static void defer_kevent(struct eth_dev *dev, int flag)
@@ -526,7 +520,7 @@ static int eth_start_xmit(struct sk_buff *skb, struct net_device *net)
         */
        if (list_empty(&dev->tx_reqs)) {
                spin_unlock_irqrestore(&dev->req_lock, flags);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        req = container_of(dev->tx_reqs.next, struct usb_request, list);
@@ -716,6 +710,14 @@ static int __init get_ether_addr(const char *str, u8 *dev_addr)
 
 static struct eth_dev *the_dev;
 
+static const struct net_device_ops eth_netdev_ops = {
+       .ndo_open               = eth_open,
+       .ndo_stop               = eth_stop,
+       .ndo_start_xmit         = eth_start_xmit,
+       .ndo_change_mtu         = ueth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
 
 /**
  * gether_setup - initialize one ethernet-over-usb link
@@ -764,12 +766,8 @@ int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
        if (ethaddr)
                memcpy(ethaddr, dev->host_mac, ETH_ALEN);
 
-       net->change_mtu = eth_change_mtu;
-       net->hard_start_xmit = eth_start_xmit;
-       net->open = eth_open;
-       net->stop = eth_stop;
-       /* watchdog_timeo, tx_timeout ... */
-       /* set_multicast_list */
+       net->netdev_ops = &eth_netdev_ops;
+
        SET_ETHTOOL_OPS(net, &ops);
 
        /* two kinds of host-initiated state changes:
@@ -787,10 +785,8 @@ int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
                dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
                free_netdev(net);
        } else {
-               DECLARE_MAC_BUF(tmp);
-
-               INFO(dev, "MAC %s\n", print_mac(tmp, net->dev_addr));
-               INFO(dev, "HOST MAC %s\n", print_mac(tmp, dev->host_mac));
+               INFO(dev, "MAC %pM\n", net->dev_addr);
+               INFO(dev, "HOST MAC %pM\n", dev->host_mac);
 
                the_dev = dev;
        }
@@ -873,6 +869,13 @@ struct net_device *gether_connect(struct gether *link)
                spin_lock(&dev->lock);
                dev->port_usb = link;
                link->ioport = dev;
+               if (netif_running(dev->net)) {
+                       if (link->open)
+                               link->open(link);
+               } else {
+                       if (link->close)
+                               link->close(link);
+               }
                spin_unlock(&dev->lock);
 
                netif_carrier_on(dev->net);