fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / eepro.c
index cd24756..b446309 100644 (file)
@@ -154,7 +154,7 @@ static const char version[] =
 #include <asm/dma.h>
 
 #define DRV_NAME "eepro"
-#define DRV_VERSION "0.13b"
+#define DRV_VERSION "0.13c"
 
 #define compat_dev_kfree_skb( skb, mode ) dev_kfree_skb( (skb) )
 /* I had reports of looong delays with SLOW_DOWN defined as udelay(2) */
@@ -311,7 +311,7 @@ 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 irqreturn_t eepro_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+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);
 static int     eepro_close(struct net_device *dev);
@@ -552,8 +552,7 @@ static int __init do_eepro_probe(struct net_device *dev)
        {
                unsigned short int WS[32]=WakeupSeq;
 
-               if (check_region(WakeupPort, 2)==0) {
-
+               if (request_region(WakeupPort, 2, "eepro wakeup")) {
                        if (net_debug>5)
                                printk(KERN_DEBUG "Waking UP\n");
 
@@ -563,7 +562,10 @@ static int __init do_eepro_probe(struct net_device *dev)
                                outb_p(WS[i],WakeupPort);
                                if (net_debug>5) printk(KERN_DEBUG ": %#x ",WS[i]);
                        }
-               } else printk(KERN_WARNING "Checkregion Failed!\n");
+
+                       release_region(WakeupPort, 2);
+               } else
+                       printk(KERN_WARNING "PnP wakeup region busy!\n");
        }
 #endif
 
@@ -600,12 +602,7 @@ struct net_device * __init eepro_probe(int unit)
        err = do_eepro_probe(dev);
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       release_region(dev->base_addr, EEPRO_IO_EXTENT);
 out:
        free_netdev(dev);
        return ERR_PTR(err);
@@ -710,7 +707,7 @@ static void __init eepro_print_info (struct net_device *dev)
                                        dev->name, (unsigned)dev->base_addr);
                        break;
                case LAN595FX:
-                       printk("%s: Intel EtherExpress Pro/10+ ISA\n at %#x,", 
+                       printk("%s: Intel EtherExpress Pro/10+ ISA\n at %#x,",
                                        dev->name, (unsigned)dev->base_addr);
                        break;
                case LAN595TX:
@@ -718,7 +715,7 @@ static void __init eepro_print_info (struct net_device *dev)
                                        dev->name, (unsigned)dev->base_addr);
                        break;
                case LAN595:
-                       printk("%s: Intel 82595-based lan card at %#x,", 
+                       printk("%s: Intel 82595-based lan card at %#x,",
                                        dev->name, (unsigned)dev->base_addr);
        }
 
@@ -731,7 +728,7 @@ static void __init eepro_print_info (struct net_device *dev)
 
        if (dev->irq > 2)
                printk(", IRQ %d, %s.\n", dev->irq, ifmap[dev->if_port]);
-       else 
+       else
                printk(", %s.\n", ifmap[dev->if_port]);
 
        if (net_debug > 3) {
@@ -746,7 +743,7 @@ static void __init eepro_print_info (struct net_device *dev)
                printEEPROMInfo(dev);
 }
 
-static struct ethtool_ops eepro_ethtool_ops;
+static const struct ethtool_ops eepro_ethtool_ops;
 
 /* 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
@@ -758,9 +755,10 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
        int i;
        struct eepro_local *lp;
        int ioaddr = dev->base_addr;
+       int err;
 
        /* Grab the region so we can find another board if autoIRQ fails. */
-       if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) { 
+       if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
                if (!autoprobe)
                        printk(KERN_WARNING "EEPRO: io-port 0x%04x in use \n",
                                ioaddr);
@@ -842,15 +840,15 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
                /* Mask off INT number */
                int count = lp->word[1] & 7;
                unsigned irqMask = lp->word[7];
+
                while (count--)
                        irqMask &= irqMask - 1;
+
                count = ffs(irqMask);
+
                if (count)
                        dev->irq = count - 1;
+
                if (dev->irq < 2) {
                        printk(KERN_ERR " Duh! illegal interrupt vector stored in EEPROM.\n");
                        goto exit;
@@ -858,7 +856,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
                        dev->irq = 9;
                }
        }
+
        dev->open               = eepro_open;
        dev->stop               = eepro_close;
        dev->hard_start_xmit    = eepro_send_packet;
@@ -867,16 +865,22 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
        dev->tx_timeout         = eepro_tx_timeout;
        dev->watchdog_timeo     = TX_TIMEOUT;
        dev->ethtool_ops        = &eepro_ethtool_ops;
+
        /* print boot time info */
        eepro_print_info(dev);
 
        /* reset 82595 */
        eepro_reset(ioaddr);
+
+       err = register_netdev(dev);
+       if (err)
+               goto err;
        return 0;
 exit:
+       err = -ENODEV;
+err:
        release_region(dev->base_addr, EEPRO_IO_EXTENT);
-       return -ENODEV;
+       return err;
 }
 
 /* Open/initialize the board.  This is called (in the current kernel)
@@ -916,7 +920,7 @@ static int  eepro_grab_irq(struct net_device *dev)
 
                eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */
 
-               if (request_irq (*irqp, NULL, SA_SHIRQ, "bogus", dev) != EBUSY) {
+               if (request_irq (*irqp, NULL, IRQF_SHARED, "bogus", dev) != EBUSY) {
                        unsigned long irq_mask;
                        /* Twinkle the interrupt, and check if it's seen */
                        irq_mask = probe_irq_on();
@@ -990,16 +994,6 @@ static int eepro_open(struct net_device *dev)
                return -EAGAIN;
        }
 
-#ifdef irq2dev_map
-       if  (((irq2dev_map[dev->irq] != 0)
-               || (irq2dev_map[dev->irq] = dev) == 0) &&
-               (irq2dev_map[dev->irq]!=dev)) {
-               /* printk("%s: IRQ map wrong\n", dev->name); */
-               free_irq(dev->irq, dev);
-               return -EAGAIN;
-       }
-#endif
-
        /* Initialize the 82595. */
 
        eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
@@ -1045,8 +1039,8 @@ static int eepro_open(struct net_device *dev)
 
 
        /* Initialize the RCV and XMT upper and lower limits */
-       outb(lp->rcv_lower_limit >> 8, ioaddr + RCV_LOWER_LIMIT_REG); 
-       outb(lp->rcv_upper_limit >> 8, ioaddr + RCV_UPPER_LIMIT_REG); 
+       outb(lp->rcv_lower_limit >> 8, ioaddr + RCV_LOWER_LIMIT_REG);
+       outb(lp->rcv_upper_limit >> 8, ioaddr + RCV_UPPER_LIMIT_REG);
        outb(lp->xmt_lower_limit >> 8, ioaddr + lp->xmt_lower_limit_reg);
        outb(lp->xmt_upper_limit >> 8, ioaddr + lp->xmt_upper_limit_reg);
 
@@ -1063,12 +1057,12 @@ static int eepro_open(struct net_device *dev)
        eepro_clear_int(ioaddr);
 
        /* Initialize RCV */
-       outw(lp->rcv_lower_limit, ioaddr + RCV_BAR); 
+       outw(lp->rcv_lower_limit, ioaddr + RCV_BAR);
        lp->rx_start = lp->rcv_lower_limit;
-       outw(lp->rcv_upper_limit | 0xfe, ioaddr + RCV_STOP); 
+       outw(lp->rcv_upper_limit | 0xfe, ioaddr + RCV_STOP);
 
        /* Initialize XMT */
-       outw(lp->xmt_lower_limit, ioaddr + lp->xmt_bar); 
+       outw(lp->xmt_lower_limit, ioaddr + lp->xmt_bar);
        lp->tx_start = lp->tx_end = lp->xmt_lower_limit;
        lp->tx_last = 0;
 
@@ -1150,8 +1144,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
                printk(KERN_DEBUG  "%s: entering eepro_send_packet routine.\n", dev->name);
 
        if (length < ETH_ZLEN) {
-               skb = skb_padto(skb, ETH_ZLEN);
-               if (skb == NULL)
+               if (skb_padto(skb, ETH_ZLEN))
                        return 0;
                length = ETH_ZLEN;
        }
@@ -1193,19 +1186,13 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
        Handle the network interface interrupts. */
 
 static irqreturn_t
-eepro_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+eepro_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev =  (struct net_device *)dev_id;
-                             /* (struct net_device *)(irq2dev_map[irq]);*/
+       struct net_device *dev = dev_id;
        struct eepro_local *lp;
        int ioaddr, status, boguscount = 20;
        int handled = 0;
 
-       if (dev == NULL) {
-                printk (KERN_ERR "eepro_interrupt(): irq %d for unknown device.\\n", irq);
-                return IRQ_NONE;
-        }
-
        lp = netdev_priv(dev);
 
         spin_lock(&lp->lock);
@@ -1285,10 +1272,6 @@ static int eepro_close(struct net_device *dev)
        /* release the interrupt */
        free_irq(dev->irq, dev);
 
-#ifdef irq2dev_map
-       irq2dev_map[dev->irq] = 0;
-#endif
-
        /* Update the statistics here. What statistics? */
 
        return 0;
@@ -1330,7 +1313,6 @@ set_multicast_list(struct net_device *dev)
                mode = inb(ioaddr + REG3);
                outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
                eepro_sw2bank0(ioaddr); /* Return to BANK 0 now */
-               printk(KERN_INFO "%s: promiscuous mode enabled.\n", dev->name);
        }
 
        else if (dev->mc_count==0 )
@@ -1409,7 +1391,7 @@ set_multicast_list(struct net_device *dev)
                                outb(0x08, ioaddr + STATUS_REG);
 
                                if (i & 0x20) { /* command ABORTed */
-                                       printk(KERN_NOTICE "%s: multicast setup failed.\n", 
+                                       printk(KERN_NOTICE "%s: multicast setup failed.\n",
                                                dev->name);
                                        break;
                                } else if ((i & 0x0f) == 0x03)  { /* MC-Done */
@@ -1510,7 +1492,7 @@ hardware_send_packet(struct net_device *dev, void *buf, short length)
                end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
 
        if (end >= lp->xmt_upper_limit + 2) { /* the transmit buffer is wrapped around */
-               if ((lp->xmt_upper_limit + 2 - last) <= XMT_HEADER) {   
+               if ((lp->xmt_upper_limit + 2 - last) <= XMT_HEADER) {
                                /* Arrrr!!!, must keep the xmt header together,
                                several days were lost to chase this one down. */
                        last = lp->xmt_lower_limit;
@@ -1641,7 +1623,7 @@ eepro_rx(struct net_device *dev)
                        else if (rcv_status & 0x0800)
                                lp->stats.rx_crc_errors++;
 
-                       printk(KERN_DEBUG "%s: event = %#x, status = %#x, next = %#x, size = %#x\n", 
+                       printk(KERN_DEBUG "%s: event = %#x, status = %#x, next = %#x, size = %#x\n",
                                dev->name, rcv_event, rcv_status, rcv_next_frame, rcv_size);
                }
 
@@ -1672,10 +1654,10 @@ eepro_transmit_interrupt(struct net_device *dev)
 {
        struct eepro_local *lp = netdev_priv(dev);
        short ioaddr = dev->base_addr;
-       short boguscount = 25; 
+       short boguscount = 25;
        short xmt_status;
 
-       while ((lp->tx_start != lp->tx_end) && boguscount--) { 
+       while ((lp->tx_start != lp->tx_end) && boguscount--) {
 
                outw(lp->tx_start, ioaddr + HOST_ADDRESS_REG);
                xmt_status = inw(ioaddr+IO_PORT);
@@ -1721,7 +1703,7 @@ static int eepro_ethtool_get_settings(struct net_device *dev,
 {
        struct eepro_local      *lp = (struct eepro_local *)dev->priv;
 
-       cmd->supported =        SUPPORTED_10baseT_Half | 
+       cmd->supported =        SUPPORTED_10baseT_Half |
                                SUPPORTED_10baseT_Full |
                                SUPPORTED_Autoneg;
        cmd->advertising =      ADVERTISED_10baseT_Half |
@@ -1769,7 +1751,7 @@ static void eepro_ethtool_get_drvinfo(struct net_device *dev,
        sprintf(drvinfo->bus_info, "ISA 0x%lx", dev->base_addr);
 }
 
-static struct ethtool_ops eepro_ethtool_ops = {
+static const struct ethtool_ops eepro_ethtool_ops = {
        .get_settings   = eepro_ethtool_get_settings,
        .get_drvinfo    = eepro_ethtool_get_drvinfo,
 };
@@ -1795,18 +1777,16 @@ MODULE_AUTHOR("Pascal Dupuis and others");
 MODULE_DESCRIPTION("Intel i82595 ISA EtherExpressPro10/10+ driver");
 MODULE_LICENSE("GPL");
 
-static int num_params;
-module_param_array(io, int, &num_params, 0);
-module_param_array(irq, int, &num_params, 0);
-module_param_array(mem, int, &num_params, 0);
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
+module_param_array(mem, int, NULL, 0);
 module_param(autodetect, int, 0);
 MODULE_PARM_DESC(io, "EtherExpress Pro/10 I/O base addres(es)");
 MODULE_PARM_DESC(irq, "EtherExpress Pro/10 IRQ number(s)");
 MODULE_PARM_DESC(mem, "EtherExpress Pro/10 Rx buffer size(es) in kB (3-29)");
 MODULE_PARM_DESC(autodetect, "EtherExpress Pro/10 force board(s) detection (0-1)");
 
-int
-init_module(void)
+int __init init_module(void)
 {
        struct net_device *dev;
        int i;
@@ -1834,11 +1814,8 @@ init_module(void)
                dev->irq = irq[i];
 
                if (do_eepro_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_eepro[n_eepro++] = dev;
-                               continue;
-                       }
-                       release_region(dev->base_addr, EEPRO_IO_EXTENT);
+                       dev_eepro[n_eepro++] = dev;
+                       continue;
                }
                free_netdev(dev);
                break;
@@ -1850,7 +1827,7 @@ init_module(void)
        return n_eepro ? 0 : -ENODEV;
 }
 
-void
+void __exit
 cleanup_module(void)
 {
        int i;