USB: remove leftover references to udev->autosuspend_disabled
[safe/jmp/linux-2.6] / drivers / net / wan / lapbether.c
index 24fd613..98e2f99 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/net.h>
@@ -55,7 +56,6 @@ struct lapbethdev {
        struct list_head        node;
        struct net_device       *ethdev;        /* link to ethernet device */
        struct net_device       *axdev;         /* lapbeth device (lapb#) */
-       struct net_device_stats stats;          /* some statistics */
 };
 
 static LIST_HEAD(lapbeth_devices);
@@ -107,10 +107,9 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
        if (!netif_running(lapbeth->axdev))
                goto drop_unlock;
 
-       lapbeth->stats.rx_packets++;
-
        len = skb->data[0] + skb->data[1] * 256;
-       lapbeth->stats.rx_bytes += len;
+       dev->stats.rx_packets++;
+       dev->stats.rx_bytes += len;
 
        skb_pull(skb, 2);       /* Remove the length bytes */
        skb_trim(skb, len);     /* Set the length of the data */
@@ -143,55 +142,49 @@ static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb)
        *ptr = 0x00;
 
        skb->protocol = x25_type_trans(skb, dev);
-       skb->dev->last_rx = jiffies;
        return netif_rx(skb);
 }
 
 /*
  *     Send a LAPB frame via an ethernet interface
  */
-static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
+                                     struct net_device *dev)
 {
-       int err = -ENODEV;
+       int err;
 
        /*
         * Just to be *really* sure not to send anything if the interface
         * is down, the ethernet device may have gone.
         */
-       if (!netif_running(dev)) {
+       if (!netif_running(dev))
                goto drop;
-       }
 
        switch (skb->data[0]) {
        case 0x00:
-               err = 0;
                break;
        case 0x01:
                if ((err = lapb_connect_request(dev)) != LAPB_OK)
                        printk(KERN_ERR "lapbeth: lapb_connect_request "
                               "error: %d\n", err);
-               goto drop_ok;
+               goto drop;
        case 0x02:
                if ((err = lapb_disconnect_request(dev)) != LAPB_OK)
                        printk(KERN_ERR "lapbeth: lapb_disconnect_request "
                               "err: %d\n", err);
                /* Fall thru */
        default:
-               goto drop_ok;
+               goto drop;
        }
 
        skb_pull(skb, 1);
 
        if ((err = lapb_data_request(dev, skb)) != LAPB_OK) {
                printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err);
-               err = -ENOMEM;
                goto drop;
        }
-       err = 0;
 out:
-       return err;
-drop_ok:
-       err = 0;
+       return NETDEV_TX_OK;
 drop:
        kfree_skb(skb);
        goto out;
@@ -211,8 +204,8 @@ static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb)
        *ptr++ = size % 256;
        *ptr++ = size / 256;
 
-       lapbeth->stats.tx_packets++;
-       lapbeth->stats.tx_bytes += size;
+       ndev->stats.tx_packets++;
+       ndev->stats.tx_bytes += size;
 
        skb->dev = dev = lapbeth->ethdev;
 
@@ -235,7 +228,6 @@ static void lapbeth_connected(struct net_device *dev, int reason)
        *ptr = 0x01;
 
        skb->protocol = x25_type_trans(skb, dev);
-       skb->dev->last_rx = jiffies;
        netif_rx(skb);
 }
 
@@ -253,20 +245,10 @@ static void lapbeth_disconnected(struct net_device *dev, int reason)
        *ptr = 0x02;
 
        skb->protocol = x25_type_trans(skb, dev);
-       skb->dev->last_rx = jiffies;
        netif_rx(skb);
 }
 
 /*
- *     Statistics
- */
-static struct net_device_stats *lapbeth_get_stats(struct net_device *dev)
-{
-       struct lapbethdev *lapbeth = netdev_priv(dev);
-       return &lapbeth->stats;
-}
-
-/*
  *     Set AX.25 callsign
  */
 static int lapbeth_set_mac_address(struct net_device *dev, void *addr)
@@ -317,14 +299,17 @@ static int lapbeth_close(struct net_device *dev)
 
 /* ------------------------------------------------------------------------ */
 
+static const struct net_device_ops lapbeth_netdev_ops = {
+       .ndo_open            = lapbeth_open,
+       .ndo_stop            = lapbeth_close,
+       .ndo_start_xmit      = lapbeth_xmit,
+       .ndo_set_mac_address = lapbeth_set_mac_address,
+};
+
 static void lapbeth_setup(struct net_device *dev)
 {
-       dev->hard_start_xmit = lapbeth_xmit;
-       dev->open            = lapbeth_open;
-       dev->stop            = lapbeth_close;
+       dev->netdev_ops      = &lapbeth_netdev_ops;
        dev->destructor      = free_netdev;
-       dev->set_mac_address = lapbeth_set_mac_address;
-       dev->get_stats       = lapbeth_get_stats;
        dev->type            = ARPHRD_X25;
        dev->hard_header_len = 3;
        dev->mtu             = 1000;
@@ -424,8 +409,8 @@ static int lapbeth_device_event(struct notifier_block *this,
 
 /* ------------------------------------------------------------------------ */
 
-static struct packet_type lapbeth_packet_type = {
-       .type = __constant_htons(ETH_P_DEC),
+static struct packet_type lapbeth_packet_type __read_mostly = {
+       .type = cpu_to_be16(ETH_P_DEC),
        .func = lapbeth_rcv,
 };
 
@@ -433,7 +418,8 @@ static struct notifier_block lapbeth_dev_notifier = {
        .notifier_call = lapbeth_device_event,
 };
 
-static char banner[] __initdata = KERN_INFO "LAPB Ethernet driver version 0.02\n";
+static const char banner[] __initconst =
+       KERN_INFO "LAPB Ethernet driver version 0.02\n";
 
 static int __init lapbeth_init_driver(void)
 {