netxen: sanitize variable names
[safe/jmp/linux-2.6] / drivers / net / hamradio / yam.c
index bfcf201..500a40b 100644 (file)
@@ -42,7 +42,6 @@
 
 /*****************************************************************************/
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/net.h>
@@ -51,6 +50,7 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/bitops.h>
+#include <linux/random.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <linux/interrupt.h>
@@ -65,6 +65,7 @@
 #include <linux/kernel.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <net/net_namespace.h>
 
 #include <asm/uaccess.h>
 #include <linux/init.h>
@@ -76,7 +77,8 @@
 /* --------------------------------------------------------------------- */
 
 static const char yam_drvname[] = "yam";
-static char yam_drvinfo[] __initdata = KERN_INFO "YAM driver version 0.8 by F1OAT/F6FBB\n";
+static const char yam_drvinfo[] __initdata = KERN_INFO \
+       "YAM driver version 0.8 by F1OAT/F6FBB\n";
 
 /* --------------------------------------------------------------------- */
 
@@ -114,10 +116,6 @@ struct yam_port {
 
        struct net_device *dev;
 
-       /* Stats section */
-
-       struct net_device_stats stats;
-
        int nb_rxint;
        int nb_mdint;
 
@@ -157,11 +155,6 @@ static struct net_device *yam_devs[NR_PORTS];
 
 static struct yam_mcs *yam_data;
 
-static char ax25_bcast[7] =
-{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
-static char ax25_test[7] =
-{'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1};
-
 static DEFINE_TIMER(yam_timer, NULL, 0, 0);
 
 /* --------------------------------------------------------------------- */
@@ -511,7 +504,7 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
                } else {
                        if (!(skb = dev_alloc_skb(pkt_len))) {
                                printk(KERN_WARNING "%s: memory squeeze, dropping packet\n", dev->name);
-                               ++yp->stats.rx_dropped;
+                               ++dev->stats.rx_dropped;
                        } else {
                                unsigned char *cp;
                                cp = skb_put(skb, pkt_len);
@@ -519,8 +512,7 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
                                memcpy(cp, yp->rx_buf, pkt_len - 1);
                                skb->protocol = ax25_type_trans(skb, dev);
                                netif_rx(skb);
-                               dev->last_rx = jiffies;
-                               ++yp->stats.rx_packets;
+                               ++dev->stats.rx_packets;
                        }
                }
        }
@@ -572,14 +564,6 @@ static void yam_start_tx(struct net_device *dev, struct yam_port *yp)
        ptt_on(dev);
 }
 
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
-       random_seed = 28629 * random_seed + 157;
-       return random_seed;
-}
-
 static void yam_arbitrate(struct net_device *dev)
 {
        struct yam_port *yp = netdev_priv(dev);
@@ -606,7 +590,7 @@ static void yam_arbitrate(struct net_device *dev)
        yp->slotcnt = yp->slot / 10;
 
        /* is random > persist ? */
-       if ((random_num() % 256) > yp->pers)
+       if ((random32() % 256) > yp->pers)
                return;
 
        yam_start_tx(dev, yp);
@@ -651,7 +635,9 @@ static void yam_tx_byte(struct net_device *dev, struct yam_port *yp)
                                dev_kfree_skb_any(skb);
                                break;
                        }
-                       memcpy(yp->tx_buf, skb->data + 1, yp->tx_len);
+                       skb_copy_from_linear_data_offset(skb, 1,
+                                                        yp->tx_buf,
+                                                        yp->tx_len);
                        dev_kfree_skb_any(skb);
                        yp->tx_count = 0;
                        yp->tx_crcl = 0x21;
@@ -688,7 +674,7 @@ static void yam_tx_byte(struct net_device *dev, struct yam_port *yp)
                        yp->tx_count = 1;
                        yp->tx_state = TX_HEAD;
                }
-               ++yp->stats.tx_packets;
+               ++dev->stats.tx_packets;
                break;
        case TX_TAIL:
                if (--yp->tx_count <= 0) {
@@ -703,7 +689,7 @@ static void yam_tx_byte(struct net_device *dev, struct yam_port *yp)
 * ISR routine
 ************************************************************************************/
 
-static irqreturn_t yam_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t yam_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev;
        struct yam_port *yp;
@@ -727,7 +713,7 @@ static irqreturn_t yam_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                        handled = 1;
 
                        if (lsr & LSR_OE)
-                               ++yp->stats.rx_fifo_errors;
+                               ++dev->stats.rx_fifo_errors;
 
                        yp->dcd = (msr & RX_DCD) ? 1 : 0;
 
@@ -789,16 +775,16 @@ static int yam_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq, "  TxTail   %u\n", yp->txtail);
        seq_printf(seq, "  SlotTime %u\n", yp->slot);
        seq_printf(seq, "  Persist  %u\n", yp->pers);
-       seq_printf(seq, "  TxFrames %lu\n", yp->stats.tx_packets);
-       seq_printf(seq, "  RxFrames %lu\n", yp->stats.rx_packets);
+       seq_printf(seq, "  TxFrames %lu\n", dev->stats.tx_packets);
+       seq_printf(seq, "  RxFrames %lu\n", dev->stats.rx_packets);
        seq_printf(seq, "  TxInt    %u\n", yp->nb_mdint);
        seq_printf(seq, "  RxInt    %u\n", yp->nb_rxint);
-       seq_printf(seq, "  RxOver   %lu\n", yp->stats.rx_fifo_errors);
+       seq_printf(seq, "  RxOver   %lu\n", dev->stats.rx_fifo_errors);
        seq_printf(seq, "\n");
        return 0;
 }
 
-static struct seq_operations yam_seqops = {
+static const struct seq_operations yam_seqops = {
        .start = yam_seq_start,
        .next = yam_seq_next,
        .stop = yam_seq_stop,
@@ -810,7 +796,7 @@ static int yam_info_open(struct inode *inode, struct file *file)
        return seq_open(file, &yam_seqops);
 }
 
-static struct file_operations yam_info_fops = {
+static const struct file_operations yam_info_fops = {
        .owner = THIS_MODULE,
        .open = yam_info_open,
        .read = seq_read,
@@ -823,26 +809,6 @@ static struct file_operations yam_info_fops = {
 
 /* --------------------------------------------------------------------- */
 
-static struct net_device_stats *yam_get_stats(struct net_device *dev)
-{
-       struct yam_port *yp;
-
-       if (!dev)
-               return NULL;
-
-       yp = netdev_priv(dev);
-       if (yp->magic != YAM_MAGIC)
-               return NULL;
-
-       /* 
-        * Get the current statistics.  This may be called with the
-        * card open or closed. 
-        */
-       return &yp->stats;
-}
-
-/* --------------------------------------------------------------------- */
-
 static int yam_open(struct net_device *dev)
 {
        struct yam_port *yp = netdev_priv(dev);
@@ -874,7 +840,7 @@ static int yam_open(struct net_device *dev)
                goto out_release_base;
        }
        outb(0, IER(dev->base_addr));
-       if (request_irq(dev->irq, yam_interrupt, SA_INTERRUPT | SA_SHIRQ, dev->name, dev)) {
+       if (request_irq(dev->irq, yam_interrupt, IRQF_DISABLED | IRQF_SHARED, dev->name, dev)) {
                printk(KERN_ERR "%s: irq %d busy\n", dev->name, dev->irq);
                ret = -EBUSY;
                goto out_release_base;
@@ -888,10 +854,10 @@ static int yam_open(struct net_device *dev)
 
        /* Reset overruns for all ports - FPGA programming makes overruns */
        for (i = 0; i < NR_PORTS; i++) {
-               struct net_device *dev = yam_devs[i];
-               struct yam_port *yp = netdev_priv(dev);
-               inb(LSR(dev->base_addr));
-               yp->stats.rx_fifo_errors = 0;
+               struct net_device *yam_dev = yam_devs[i];
+
+               inb(LSR(yam_dev->base_addr));
+               yam_dev->stats.rx_fifo_errors = 0;
        }
 
        printk(KERN_INFO "%s at iobase 0x%lx irq %u uart %s\n", dev->name, dev->base_addr, dev->irq,
@@ -1079,6 +1045,14 @@ static int yam_set_mac_address(struct net_device *dev, void *addr)
 
 /* --------------------------------------------------------------------- */
 
+static const struct net_device_ops yam_netdev_ops = {
+       .ndo_open            = yam_open,
+       .ndo_stop            = yam_close,
+       .ndo_start_xmit      = yam_send_packet,
+       .ndo_do_ioctl        = yam_ioctl,
+       .ndo_set_mac_address = yam_set_mac_address,
+};
+
 static void yam_setup(struct net_device *dev)
 {
        struct yam_port *yp = netdev_priv(dev);
@@ -1098,27 +1072,18 @@ static void yam_setup(struct net_device *dev)
 
        dev->base_addr = yp->iobase;
        dev->irq = yp->irq;
-       SET_MODULE_OWNER(dev);
-
-       dev->open = yam_open;
-       dev->stop = yam_close;
-       dev->do_ioctl = yam_ioctl;
-       dev->hard_start_xmit = yam_send_packet;
-       dev->get_stats = yam_get_stats;
 
        skb_queue_head_init(&yp->send_queue);
 
-       dev->hard_header = ax25_encapsulate;
-       dev->rebuild_header = ax25_rebuild_header;
-
-       dev->set_mac_address = yam_set_mac_address;
+       dev->netdev_ops = &yam_netdev_ops;
+       dev->header_ops = &ax25_header_ops;
 
        dev->type = ARPHRD_AX25;
        dev->hard_header_len = AX25_MAX_HEADER_LEN;
        dev->mtu = AX25_MTU;
        dev->addr_len = AX25_ADDR_LEN;
-       memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
-       memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);
+       memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
+       memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
 }
 
 static int __init yam_init_driver(void)
@@ -1154,7 +1119,7 @@ static int __init yam_init_driver(void)
        yam_timer.expires = jiffies + HZ / 100;
        add_timer(&yam_timer);
 
-       proc_net_fops_create("yam", S_IRUGO, &yam_info_fops);
+       proc_net_fops_create(&init_net, "yam", S_IRUGO, &yam_info_fops);
        return 0;
  error:
        while (--i >= 0) {
@@ -1186,7 +1151,7 @@ static void __exit yam_cleanup_driver(void)
                kfree(p);
        }
 
-       proc_net_remove("yam");
+       proc_net_remove(&init_net, "yam");
 }
 
 /* --------------------------------------------------------------------- */