qlcnic: fix caching window register
[safe/jmp/linux-2.6] / drivers / net / eepro.c
index 56f5049..8d97f16 100644 (file)
@@ -137,7 +137,6 @@ static const char version[] =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
@@ -309,7 +308,8 @@ struct eepro_local {
 
 static int     eepro_probe1(struct net_device *dev, int autoprobe);
 static int     eepro_open(struct net_device *dev);
-static int     eepro_send_packet(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t eepro_send_packet(struct sk_buff *skb,
+                                    struct net_device *dev);
 static irqreturn_t eepro_interrupt(int irq, void *dev_id);
 static void    eepro_rx(struct net_device *dev);
 static void    eepro_transmit_interrupt(struct net_device *dev);
@@ -605,7 +605,7 @@ out:
 
 static void __init printEEPROMInfo(struct net_device *dev)
 {
-       struct eepro_local *lp = (struct eepro_local *)dev->priv;
+       struct eepro_local *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        unsigned short Word;
        int i,j;
@@ -645,7 +645,7 @@ static void __init printEEPROMInfo(struct net_device *dev)
        if (GetBit(Word,ee_PortTPE)) printk(KERN_DEBUG "TPE ");
        if (GetBit(Word,ee_PortBNC)) printk(KERN_DEBUG "BNC ");
        if (GetBit(Word,ee_PortAUI)) printk(KERN_DEBUG "AUI ");
-       printk(KERN_DEBUG "port(s) \n");
+       printk(KERN_DEBUG "port(s)\n");
 
        Word = lp->word[6];
        printk(KERN_DEBUG "Word6:\n");
@@ -690,7 +690,6 @@ static void __init eepro_print_info (struct net_device *dev)
        struct eepro_local *    lp = netdev_priv(dev);
        int                     i;
        const char *            ifmap[] = {"AUI", "10Base2", "10BaseT"};
-       DECLARE_MAC_BUF(mac);
 
        i = inb(dev->base_addr + ID_REG);
        printk(KERN_DEBUG " id: %#x ",i);
@@ -715,7 +714,7 @@ static void __init eepro_print_info (struct net_device *dev)
                        break;
        }
 
-       printk(" %s", print_mac(mac, dev->dev_addr));
+       printk(" %pM", dev->dev_addr);
 
        if (net_debug > 3)
                printk(KERN_DEBUG ", %dK RCV buffer",
@@ -740,6 +739,17 @@ static void __init eepro_print_info (struct net_device *dev)
 
 static const struct ethtool_ops eepro_ethtool_ops;
 
+static const struct net_device_ops eepro_netdev_ops = {
+       .ndo_open               = eepro_open,
+       .ndo_stop               = eepro_close,
+       .ndo_start_xmit         = eepro_send_packet,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_tx_timeout         = eepro_tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 /* This is the real probe routine.  Linux has a history of friendly device
    probes on the ISA bus.  A good device probe avoids doing writes, and
    verifies that the correct device exists and functions.  */
@@ -755,7 +765,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
        /* Grab the region so we can find another board if autoIRQ fails. */
        if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
                if (!autoprobe)
-                       printk(KERN_WARNING "EEPRO: io-port 0x%04x in use \n",
+                       printk(KERN_WARNING "EEPRO: io-port 0x%04x in use\n",
                                ioaddr);
                return -EBUSY;
        }
@@ -852,11 +862,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
                }
        }
 
-       dev->open               = eepro_open;
-       dev->stop               = eepro_close;
-       dev->hard_start_xmit    = eepro_send_packet;
-       dev->set_multicast_list = &set_multicast_list;
-       dev->tx_timeout         = eepro_tx_timeout;
+       dev->netdev_ops         = &eepro_netdev_ops;
        dev->watchdog_timeo     = TX_TIMEOUT;
        dev->ethtool_ops        = &eepro_ethtool_ops;
 
@@ -983,7 +989,7 @@ static int eepro_open(struct net_device *dev)
                return -EAGAIN;
        }
 
-       if (request_irq(dev->irq , &eepro_interrupt, 0, dev->name, dev)) {
+       if (request_irq(dev->irq , eepro_interrupt, 0, dev->name, dev)) {
                printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
                return -EAGAIN;
        }
@@ -1127,7 +1133,8 @@ static void eepro_tx_timeout (struct net_device *dev)
 }
 
 
-static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t eepro_send_packet(struct sk_buff *skb,
+                                    struct net_device *dev)
 {
        struct eepro_local *lp = netdev_priv(dev);
        unsigned long flags;
@@ -1139,7 +1146,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
 
        if (length < ETH_ZLEN) {
                if (skb_padto(skb, ETH_ZLEN))
-                       return 0;
+                       return NETDEV_TX_OK;
                length = ETH_ZLEN;
        }
        netif_stop_queue (dev);
@@ -1154,8 +1161,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
                        /* we won't wake queue here because we're out of space */
                        dev->stats.tx_dropped++;
                else {
-               dev->stats.tx_bytes+=skb->len;
-               dev->trans_start = jiffies;
+                       dev->stats.tx_bytes+=skb->len;
                        netif_wake_queue(dev);
                }
 
@@ -1172,7 +1178,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
        eepro_en_int(ioaddr);
        spin_unlock_irqrestore(&lp->lock, flags);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 
@@ -1279,18 +1285,11 @@ set_multicast_list(struct net_device *dev)
        struct eepro_local *lp = netdev_priv(dev);
        short ioaddr = dev->base_addr;
        unsigned short mode;
-       struct dev_mc_list *dmi=dev->mc_list;
+       struct netdev_hw_addr *ha;
+       int mc_count = netdev_mc_count(dev);
 
-       if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || dev->mc_count > 63)
+       if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || mc_count > 63)
        {
-               /*
-                *      We must make the kernel realise we had to move
-                *      into promisc mode or we start all out war on
-                *      the cable. If it was a promisc request the
-                *      flag is already set. If not we assert it.
-                */
-               dev->flags|=IFF_PROMISC;
-
                eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
                mode = inb(ioaddr + REG2);
                outb(mode | PRMSC_Mode, ioaddr + REG2);
@@ -1299,7 +1298,7 @@ set_multicast_list(struct net_device *dev)
                eepro_sw2bank0(ioaddr); /* Return to BANK 0 now */
        }
 
-       else if (dev->mc_count==0 )
+       else if (mc_count == 0)
        {
                eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
                mode = inb(ioaddr + REG2);
@@ -1329,12 +1328,10 @@ set_multicast_list(struct net_device *dev)
                outw(MC_SETUP, ioaddr + IO_PORT);
                outw(0, ioaddr + IO_PORT);
                outw(0, ioaddr + IO_PORT);
-               outw(6*(dev->mc_count + 1), ioaddr + IO_PORT);
+               outw(6 * (mc_count + 1), ioaddr + IO_PORT);
 
-               for (i = 0; i < dev->mc_count; i++)
-               {
-                       eaddrs=(unsigned short *)dmi->dmi_addr;
-                       dmi=dmi->next;
+               netdev_for_each_mc_addr(ha, dev) {
+                       eaddrs = (unsigned short *) ha->addr;
                        outw(*eaddrs++, ioaddr + IO_PORT);
                        outw(*eaddrs++, ioaddr + IO_PORT);
                        outw(*eaddrs++, ioaddr + IO_PORT);
@@ -1348,7 +1345,7 @@ set_multicast_list(struct net_device *dev)
                outb(MC_SETUP, ioaddr);
 
                /* Update the transmit queue */
-               i = lp->tx_end + XMT_HEADER + 6*(dev->mc_count + 1);
+               i = lp->tx_end + XMT_HEADER + 6 * (mc_count + 1);
 
                if (lp->tx_start != lp->tx_end)
                {
@@ -1380,8 +1377,8 @@ set_multicast_list(struct net_device *dev)
                                        break;
                                } else if ((i & 0x0f) == 0x03)  { /* MC-Done */
                                        printk(KERN_DEBUG "%s: set Rx mode to %d address%s.\n",
-                                               dev->name, dev->mc_count,
-                                               dev->mc_count > 1 ? "es":"");
+                                               dev->name, mc_count,
+                                               mc_count > 1 ? "es":"");
                                        break;
                                }
                        }
@@ -1404,7 +1401,7 @@ set_multicast_list(struct net_device *dev)
 #define eeprom_delay() { udelay(40); }
 #define EE_READ_CMD (6 << 6)
 
-int
+static int
 read_eeprom(int ioaddr, int location, struct net_device *dev)
 {
        int i;
@@ -1589,7 +1586,6 @@ eepro_rx(struct net_device *dev)
 
                        skb->protocol = eth_type_trans(skb,dev);
                        netif_rx(skb);
-                       dev->last_rx = jiffies;
                        dev->stats.rx_packets++;
                }
 
@@ -1684,7 +1680,7 @@ eepro_transmit_interrupt(struct net_device *dev)
 static int eepro_ethtool_get_settings(struct net_device *dev,
                                        struct ethtool_cmd *cmd)
 {
-       struct eepro_local      *lp = (struct eepro_local *)dev->priv;
+       struct eepro_local      *lp = netdev_priv(dev);
 
        cmd->supported =        SUPPORTED_10baseT_Half |
                                SUPPORTED_10baseT_Full |
@@ -1787,7 +1783,7 @@ int __init init_module(void)
                printk(KERN_INFO "eepro_init_module: Auto-detecting boards (May God protect us...)\n");
        }
 
-       for (i = 0; io[i] != -1 && i < MAX_EEPRO; i++) {
+       for (i = 0; i < MAX_EEPRO && io[i] != -1; i++) {
                dev = alloc_etherdev(sizeof(struct eepro_local));
                if (!dev)
                        break;