[PATCH] net drivers: fix section attributes for gcc
[safe/jmp/linux-2.6] / drivers / net / natsemi.c
index e363f9b..9062775 100644 (file)
@@ -226,7 +226,7 @@ static int full_duplex[MAX_UNITS];
                                 NATSEMI_PG1_NREGS)
 #define NATSEMI_REGS_VER       1 /* v1 added RFDR registers */
 #define NATSEMI_REGS_SIZE      (NATSEMI_NREGS * sizeof(u32))
-#define NATSEMI_EEPROM_SIZE    24 /* 12 16-bit values */
+#define NATSEMI_DEF_EEPROM_SIZE        24 /* 12 16-bit values */
 
 /* Buffer sizes:
  * The nic writes 32-bit values, even if the upper bytes of
@@ -238,7 +238,7 @@ static int full_duplex[MAX_UNITS];
 #define NATSEMI_RX_LIMIT       2046    /* maximum supported by hardware */
 
 /* These identify the driver base version and may not be removed. */
-static char version[] __devinitdata =
+static const char version[] __devinitdata =
   KERN_INFO DRV_NAME " dp8381x driver, version "
       DRV_VERSION ", " DRV_RELDATE "\n"
   KERN_INFO "  originally by Donald Becker <becker@scyld.com>\n"
@@ -714,6 +714,8 @@ struct netdev_private {
        unsigned int iosize;
        spinlock_t lock;
        u32 msg_enable;
+       /* EEPROM data */
+       int eeprom_size;
 };
 
 static void move_int_phy(struct net_device *dev, int addr);
@@ -890,6 +892,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
        np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
        np->hands_off = 0;
        np->intr_status = 0;
+       np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE;
 
        /* Initial port:
         * - If the nic was configured to use an external phy and if find_mii
@@ -1498,6 +1501,31 @@ static void natsemi_reset(struct net_device *dev)
        writel(rfcr, ioaddr + RxFilterAddr);
 }
 
+static void reset_rx(struct net_device *dev)
+{
+       int i;
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = ns_ioaddr(dev);
+
+       np->intr_status &= ~RxResetDone;
+
+       writel(RxReset, ioaddr + ChipCmd);
+
+       for (i=0;i<NATSEMI_HW_TIMEOUT;i++) {
+               np->intr_status |= readl(ioaddr + IntrStatus);
+               if (np->intr_status & RxResetDone)
+                       break;
+               udelay(15);
+       }
+       if (i==NATSEMI_HW_TIMEOUT) {
+               printk(KERN_WARNING "%s: RX reset did not complete in %d usec.\n",
+                      dev->name, i*15);
+       } else if (netif_msg_hw(np)) {
+               printk(KERN_WARNING "%s: RX reset took %d usec.\n",
+                      dev->name, i*15);
+       }
+}
+
 static void natsemi_reload_eeprom(struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
@@ -2292,6 +2320,23 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)
                                                "status %#08x.\n", dev->name,
                                                np->cur_rx, desc_status);
                                np->stats.rx_length_errors++;
+
+                               /* The RX state machine has probably
+                                * locked up beneath us.  Follow the
+                                * reset procedure documented in
+                                * AN-1287. */
+
+                               spin_lock_irq(&np->lock);
+                               reset_rx(dev);
+                               reinit_rx(dev);
+                               writel(np->ring_dma, ioaddr + RxRingPtr);
+                               check_link(dev);
+                               spin_unlock_irq(&np->lock);
+
+                               /* We'll enable RX on exit from this
+                                * function. */
+                               break;
+
                        } else {
                                /* There was an error. */
                                np->stats.rx_errors++;
@@ -2540,7 +2585,8 @@ static int get_regs_len(struct net_device *dev)
 
 static int get_eeprom_len(struct net_device *dev)
 {
-       return NATSEMI_EEPROM_SIZE;
+       struct netdev_private *np = netdev_priv(dev);
+       return np->eeprom_size;
 }
 
 static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
@@ -2627,15 +2673,20 @@ static u32 get_link(struct net_device *dev)
 static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data)
 {
        struct netdev_private *np = netdev_priv(dev);
-       u8 eebuf[NATSEMI_EEPROM_SIZE];
+       u8 *eebuf;
        int res;
 
+       eebuf = kmalloc(np->eeprom_size, GFP_KERNEL);
+       if (!eebuf)
+               return -ENOMEM;
+
        eeprom->magic = PCI_VENDOR_ID_NS | (PCI_DEVICE_ID_NS_83815<<16);
        spin_lock_irq(&np->lock);
        res = netdev_get_eeprom(dev, eebuf);
        spin_unlock_irq(&np->lock);
        if (!res)
                memcpy(data, eebuf+eeprom->offset, eeprom->len);
+       kfree(eebuf);
        return res;
 }
 
@@ -2991,9 +3042,10 @@ static int netdev_get_eeprom(struct net_device *dev, u8 *buf)
        int i;
        u16 *ebuf = (u16 *)buf;
        void __iomem * ioaddr = ns_ioaddr(dev);
+       struct netdev_private *np = netdev_priv(dev);
 
        /* eeprom_read reads 16 bits, and indexes by 16 bits */
-       for (i = 0; i < NATSEMI_EEPROM_SIZE/2; i++) {
+       for (i = 0; i < np->eeprom_size/2; i++) {
                ebuf[i] = eeprom_read(ioaddr, i);
                /* The EEPROM itself stores data bit-swapped, but eeprom_read
                 * reads it back "sanely". So we swap it back here in order to