prism54: convert to internal net_device_stats
[safe/jmp/linux-2.6] / drivers / net / hamradio / bpqether.c
index 5ddf8b0..d509b37 100644 (file)
@@ -87,7 +87,8 @@
 
 #include <linux/bpqether.h>
 
-static char banner[] __initdata = KERN_INFO "AX.25: bpqether driver version 004\n";
+static const char banner[] __initdata = KERN_INFO \
+       "AX.25: bpqether driver version 004\n";
 
 static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
 
@@ -96,8 +97,8 @@ static char bpq_eth_addr[6];
 static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
 static int bpq_device_event(struct notifier_block *, unsigned long, void *);
 
-static struct packet_type bpq_packet_type = {
-       .type   = __constant_htons(ETH_P_BPQ),
+static struct packet_type bpq_packet_type __read_mostly = {
+       .type   = cpu_to_be16(ETH_P_BPQ),
        .func   = bpq_rcv,
 };
 
@@ -110,7 +111,6 @@ struct bpqdev {
        struct list_head bpq_list;      /* list of bpq devices chain */
        struct net_device *ethdev;      /* link to ethernet device */
        struct net_device *axdev;       /* bpq device (bpq#) */
-       struct net_device_stats stats;  /* some statistics */
        char   dest_addr[6];            /* ether destination address */
        char   acpt_addr[6];            /* accept ether frames from this address only */
 };
@@ -123,6 +123,20 @@ static LIST_HEAD(bpq_devices);
  * off into a separate class since they always nest.
  */
 static struct lock_class_key bpq_netdev_xmit_lock_key;
+static struct lock_class_key bpq_netdev_addr_lock_key;
+
+static void bpq_set_lockdep_class_one(struct net_device *dev,
+                                     struct netdev_queue *txq,
+                                     void *_unused)
+{
+       lockdep_set_class(&txq->_xmit_lock, &bpq_netdev_xmit_lock_key);
+}
+
+static void bpq_set_lockdep_class(struct net_device *dev)
+{
+       lockdep_set_class(&dev->addr_list_lock, &bpq_netdev_addr_lock_key);
+       netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL);
+}
 
 /* ------------------------------------------------------------------------ */
 
@@ -172,7 +186,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
        struct ethhdr *eth;
        struct bpqdev *bpq;
 
-       if (dev->nd_net != &init_net)
+       if (dev_net(dev) != &init_net)
                goto drop;
 
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
@@ -208,15 +222,14 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
        skb_pull(skb, 2);       /* Remove the length bytes */
        skb_trim(skb, len);     /* Set the length of the data */
 
-       bpq->stats.rx_packets++;
-       bpq->stats.rx_bytes += len;
+       dev->stats.rx_packets++;
+       dev->stats.rx_bytes += len;
 
        ptr = skb_push(skb, 1);
        *ptr = 0;
 
        skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
-       dev->last_rx = jiffies;
 unlock:
 
        rcu_read_unlock();
@@ -279,7 +292,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
        bpq = netdev_priv(dev);
 
        if ((dev = bpq_get_ether_dev(dev)) == NULL) {
-               bpq->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
                kfree_skb(skb);
                return -ENODEV;
        }
@@ -287,8 +300,8 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
        skb->protocol = ax25_type_trans(skb, dev);
        skb_reset_network_header(skb);
        dev_hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
-       bpq->stats.tx_packets++;
-       bpq->stats.tx_bytes+=skb->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes+=skb->len;
   
        dev_queue_xmit(skb);
        netif_wake_queue(dev);
@@ -296,16 +309,6 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
 }
 
 /*
- *     Statistics
- */
-static struct net_device_stats *bpq_get_stats(struct net_device *dev)
-{
-       struct bpqdev *bpq = netdev_priv(dev);
-
-       return &bpq->stats;
-}
-
-/*
  *     Set AX.25 callsign
  */
 static int bpq_set_mac_address(struct net_device *dev, void *addr)
@@ -383,6 +386,7 @@ static int bpq_close(struct net_device *dev)
  *     Proc filesystem
  */
 static void *bpq_seq_start(struct seq_file *seq, loff_t *pos)
+       __acquires(RCU)
 {
        int i = 1;
        struct bpqdev *bpqdev;
@@ -415,6 +419,7 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 }
 
 static void bpq_seq_stop(struct seq_file *seq, void *v)
+       __releases(RCU)
 {
        rcu_read_unlock();
 }
@@ -427,22 +432,21 @@ static int bpq_seq_show(struct seq_file *seq, void *v)
                         "dev   ether      destination        accept from\n");
        else {
                const struct bpqdev *bpqdev = v;
-               DECLARE_MAC_BUF(mac);
 
-               seq_printf(seq, "%-5s %-10s %s  ",
+               seq_printf(seq, "%-5s %-10s %pM  ",
                        bpqdev->axdev->name, bpqdev->ethdev->name,
-                       print_mac(mac, bpqdev->dest_addr));
+                       bpqdev->dest_addr);
 
                if (is_multicast_ether_addr(bpqdev->acpt_addr))
                        seq_printf(seq, "*\n");
                else
-                       seq_printf(seq, "%s\n", print_mac(mac, bpqdev->acpt_addr));
+                       seq_printf(seq, "%pM\n", bpqdev->acpt_addr);
 
        }
        return 0;
 }
 
-static struct seq_operations bpq_seqops = {
+static const struct seq_operations bpq_seqops = {
        .start = bpq_seq_start,
        .next = bpq_seq_next,
        .stop = bpq_seq_stop,
@@ -465,16 +469,17 @@ static const struct file_operations bpq_info_fops = {
 
 /* ------------------------------------------------------------------------ */
 
+static const struct net_device_ops bpq_netdev_ops = {
+       .ndo_open            = bpq_open,
+       .ndo_stop            = bpq_close,
+       .ndo_start_xmit      = bpq_xmit,
+       .ndo_set_mac_address = bpq_set_mac_address,
+       .ndo_do_ioctl        = bpq_ioctl,
+};
 
 static void bpq_setup(struct net_device *dev)
 {
-
-       dev->hard_start_xmit = bpq_xmit;
-       dev->open            = bpq_open;
-       dev->stop            = bpq_close;
-       dev->set_mac_address = bpq_set_mac_address;
-       dev->get_stats       = bpq_get_stats;
-       dev->do_ioctl        = bpq_ioctl;
+       dev->netdev_ops      = &bpq_netdev_ops;
        dev->destructor      = free_netdev;
 
        memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
@@ -523,7 +528,7 @@ static int bpq_new_device(struct net_device *edev)
        err = register_netdevice(ndev);
        if (err)
                goto error;
-       lockdep_set_class(&ndev->_xmit_lock, &bpq_netdev_xmit_lock_key);
+       bpq_set_lockdep_class(ndev);
 
        /* List protected by RTNL */
        list_add_rcu(&bpq->bpq_list, &bpq_devices);
@@ -553,7 +558,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
 {
        struct net_device *dev = (struct net_device *)ptr;
 
-       if (dev->nd_net != &init_net)
+       if (dev_net(dev) != &init_net)
                return NOTIFY_DONE;
 
        if (!dev_is_ethdev(dev))