Merge master.kernel.org:/home/rmk/linux-2.6-arm
[safe/jmp/linux-2.6] / drivers / net / atarilance.c
index ebf1a3a..a8686bf 100644 (file)
@@ -53,7 +53,6 @@ static char version[] = "atarilance.c: v1.3 04/04/96 "
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
@@ -243,7 +242,7 @@ struct lance_private {
 
 /* Possible memory/IO addresses for probing */
 
-struct lance_addr {
+static struct lance_addr {
        unsigned long   memaddr;
        unsigned long   ioaddr;
        int                             slow_flag;
@@ -336,8 +335,6 @@ struct lance_addr {
 
 /***************************** Prototypes *****************************/
 
-static int addr_accessible( volatile void *regp, int wordflag, int
-                            writeflag );
 static unsigned long lance_probe1( struct net_device *dev, struct lance_addr
                                    *init_rec );
 static int lance_open( struct net_device *dev );
@@ -406,7 +403,8 @@ struct net_device * __init atarilance_probe(int unit)
 
 /* Derived from hwreg_present() in atari/config.c: */
 
-static int __init addr_accessible( volatile void *regp, int wordflag, int writeflag )
+static noinline int __init addr_accessible(volatile void *regp, int wordflag,
+                                          int writeflag)
 {
        int             ret;
        long    flags;
@@ -454,6 +452,16 @@ static int __init addr_accessible( volatile void *regp, int wordflag, int writef
        return( ret );
 }
 
+static const struct net_device_ops lance_netdev_ops = {
+       .ndo_open               = lance_open,
+       .ndo_stop               = lance_close,
+       .ndo_start_xmit         = lance_start_xmit,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_set_mac_address    = lance_set_mac_address,
+       .ndo_tx_timeout         = lance_tx_timeout,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_change_mtu         = eth_change_mtu,
+};
 
 static unsigned long __init lance_probe1( struct net_device *dev,
                                           struct lance_addr *init_rec )
@@ -467,7 +475,6 @@ static unsigned long __init lance_probe1( struct net_device *dev,
        int                                     i;
        static int                              did_version;
        unsigned short                  save1, save2;
-       DECLARE_MAC_BUF(mac);
 
        PROBE_PRINT(( "Probing for Lance card at mem %#lx io %#lx\n",
                                  (long)memaddr, (long)ioaddr ));
@@ -522,7 +529,7 @@ static unsigned long __init lance_probe1( struct net_device *dev,
        return( 0 );
 
   probe_ok:
-       lp = (struct lance_private *)dev->priv;
+       lp = netdev_priv(dev);
        MEM = (struct lance_memory *)memaddr;
        IO = lp->iobase = (struct lance_ioreg *)ioaddr;
        dev->base_addr = (unsigned long)ioaddr; /* informational only */
@@ -596,7 +603,7 @@ static unsigned long __init lance_probe1( struct net_device *dev,
                i = IO->mem;
                break;
        }
-       printk("%s\n", print_mac(mac, dev->dev_addr));
+       printk("%pM\n", dev->dev_addr);
        if (lp->cardtype == OLD_RIEBL) {
                printk( "%s: Warning: This is a default ethernet address!\n",
                                dev->name );
@@ -625,15 +632,9 @@ static unsigned long __init lance_probe1( struct net_device *dev,
        if (did_version++ == 0)
                DPRINTK( 1, ( version ));
 
-       /* The LANCE-specific entries in the device structure. */
-       dev->open = &lance_open;
-       dev->hard_start_xmit = &lance_start_xmit;
-       dev->stop = &lance_close;
-       dev->set_multicast_list = &set_multicast_list;
-       dev->set_mac_address = &lance_set_mac_address;
+       dev->netdev_ops = &lance_netdev_ops;
 
        /* XXX MSch */
-       dev->tx_timeout = lance_tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
 
        return( 1 );
@@ -641,8 +642,8 @@ static unsigned long __init lance_probe1( struct net_device *dev,
 
 
 static int lance_open( struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        struct lance_ioreg       *IO = lp->iobase;
        int i;
 
@@ -661,7 +662,7 @@ static int lance_open( struct net_device *dev )
        while (--i > 0)
                if (DREG & CSR0_IDON)
                        break;
-       if (i < 0 || (DREG & CSR0_ERR)) {
+       if (i <= 0 || (DREG & CSR0_ERR)) {
                DPRINTK( 2, ( "lance_open(): opening %s failed, i=%d, csr0=%04x\n",
                                          dev->name, i, DREG ));
                DREG = CSR0_STOP;
@@ -682,8 +683,8 @@ static int lance_open( struct net_device *dev )
 /* Initialize the LANCE Rx and Tx rings. */
 
 static void lance_init_ring( struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        int i;
        unsigned offset;
 
@@ -731,7 +732,7 @@ static void lance_init_ring( struct net_device *dev )
 
 static void lance_tx_timeout (struct net_device *dev)
 {
-       struct lance_private *lp = (struct lance_private *) dev->priv;
+       struct lance_private *lp = netdev_priv(dev);
        struct lance_ioreg       *IO = lp->iobase;
 
        AREG = CSR0;
@@ -773,14 +774,12 @@ static void lance_tx_timeout (struct net_device *dev)
 /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
 
 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        struct lance_ioreg       *IO = lp->iobase;
        int entry, len;
        struct lance_tx_head *head;
        unsigned long flags;
-       DECLARE_MAC_BUF(mac);
-       DECLARE_MAC_BUF(mac2);
 
        DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n",
                                  dev->name, DREG ));
@@ -796,19 +795,17 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
 
        if (len > skb->len) {
                if (skb_padto(skb, len))
-                       return 0;
+                       return NETDEV_TX_OK;
        }
 
        netif_stop_queue (dev);
 
        /* Fill in a Tx ring entry */
        if (lance_debug >= 3) {
-               printk( "%s: TX pkt type 0x%04x from "
-                               "%s to %s"
+               printk( "%s: TX pkt type 0x%04x from %pM to %pM"
                                " data at 0x%08x len %d\n",
                                dev->name, ((u_short *)skb->data)[6],
-                               print_mac(mac, &skb->data[6]),
-                               print_mac(mac2, skb->data),
+                               &skb->data[6], skb->data,
                                (int)skb->data, (int)skb->len );
        }
 
@@ -848,7 +845,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
                lp->tx_full = 1;
        spin_unlock_irqrestore (&lp->devlock, flags);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* The LANCE interrupt handler. */
@@ -866,7 +863,7 @@ static irqreturn_t lance_interrupt( int irq, void *dev_id )
                return IRQ_NONE;
        }
 
-       lp = (struct lance_private *)dev->priv;
+       lp = netdev_priv(dev);
        IO = lp->iobase;
        spin_lock (&lp->devlock);
 
@@ -932,8 +929,8 @@ static irqreturn_t lance_interrupt( int irq, void *dev_id )
                        }
 #endif
 
-                       if (lp->tx_full && (netif_queue_stopped(dev))
-                               && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
+                       if (lp->tx_full && (netif_queue_stopped(dev)) &&
+                               dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
                                /* The ring is no longer full, clear tbusy. */
                                lp->tx_full = 0;
                                netif_wake_queue (dev);
@@ -966,8 +963,8 @@ static irqreturn_t lance_interrupt( int irq, void *dev_id )
 
 
 static int lance_rx( struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        int entry = lp->cur_rx & RX_RING_MOD_MASK;
        int i;
 
@@ -1020,14 +1017,12 @@ static int lance_rx( struct net_device *dev )
 
                                if (lance_debug >= 3) {
                                        u_char *data = PKTBUF_ADDR(head);
-                                       DECLARE_MAC_BUF(mac);
-                                       DECLARE_MAC_BUF(mac2);
 
-                                       printk(KERN_DEBUG "%s: RX pkt type 0x%04x from %s to %s ",
+                                       printk(KERN_DEBUG "%s: RX pkt type 0x%04x from %pM to %pM "
                                                   "data %02x %02x %02x %02x %02x %02x %02x %02x "
                                                   "len %d\n",
                                                   dev->name, ((u_short *)data)[6],
-                                                  print_mac(mac, &data[6]), print_mac(mac2, data),
+                                                  &data[6], data,
                                                   data[15], data[16], data[17], data[18],
                                                   data[19], data[20], data[21], data[22],
                                                   pkt_len);
@@ -1038,7 +1033,6 @@ static int lance_rx( struct net_device *dev )
                                lp->memcpy_f( skb->data, PKTBUF_ADDR(head), pkt_len );
                                skb->protocol = eth_type_trans( skb, dev );
                                netif_rx( skb );
-                               dev->last_rx = jiffies;
                                dev->stats.rx_packets++;
                                dev->stats.rx_bytes += pkt_len;
                        }
@@ -1058,8 +1052,8 @@ static int lance_rx( struct net_device *dev )
 
 
 static int lance_close( struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        struct lance_ioreg       *IO = lp->iobase;
 
        netif_stop_queue (dev);
@@ -1085,8 +1079,8 @@ static int lance_close( struct net_device *dev )
  */
 
 static void set_multicast_list( struct net_device *dev )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        struct lance_ioreg       *IO = lp->iobase;
 
        if (netif_running(dev))
@@ -1102,7 +1096,7 @@ static void set_multicast_list( struct net_device *dev )
                REGA( CSR15 ) = 0x8000; /* Set promiscuous mode */
        } else {
                short multicast_table[4];
-               int num_addrs = dev->mc_count;
+               int num_addrs = netdev_mc_count(dev);
                int i;
                /* We don't use the multicast table, but rely on upper-layer
                 * filtering. */
@@ -1127,8 +1121,8 @@ static void set_multicast_list( struct net_device *dev )
 /* This is needed for old RieblCards and possible for new RieblCards */
 
 static int lance_set_mac_address( struct net_device *dev, void *addr )
-
-{      struct lance_private *lp = (struct lance_private *)dev->priv;
+{
+       struct lance_private *lp = netdev_priv(dev);
        struct sockaddr *saddr = addr;
        int i;
 
@@ -1156,7 +1150,7 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
 #ifdef MODULE
 static struct net_device *atarilance_dev;
 
-int __init init_module(void)
+static int __init atarilance_module_init(void)
 {
        atarilance_dev = atarilance_probe(-1);
        if (IS_ERR(atarilance_dev))
@@ -1164,13 +1158,14 @@ int __init init_module(void)
        return 0;
 }
 
-void __exit cleanup_module(void)
+static void __exit atarilance_module_exit(void)
 {
        unregister_netdev(atarilance_dev);
        free_irq(atarilance_dev->irq, atarilance_dev);
        free_netdev(atarilance_dev);
 }
-
+module_init(atarilance_module_init);
+module_exit(atarilance_module_exit);
 #endif /* MODULE */