Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / ns83820.c
index c336b46..b6427a8 100644 (file)
 #include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/ip.h>  /* for iph */
 #include <linux/in.h>  /* for IPPROTO_... */
-#include <linux/eeprom.h>
 #include <linux/compiler.h>
 #include <linux/prefetch.h>
 #include <linux/ethtool.h>
 #include <linux/timer.h>
 #include <linux/if_vlan.h>
+#include <linux/rtnetlink.h>
+#include <linux/jiffies.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -444,7 +446,6 @@ struct ns83820 {
 
        u32                     MEAR_cache;
        u32                     IMR_cache;
-       struct eeprom           ee;
 
        unsigned                linkstate;
 
@@ -567,13 +568,12 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
 #endif
 
        sg = dev->rx_info.descs + (next_empty * DESC_SIZE);
-       if (unlikely(NULL != dev->rx_info.skbs[next_empty]))
-               BUG();
+       BUG_ON(NULL != dev->rx_info.skbs[next_empty]);
        dev->rx_info.skbs[next_empty] = skb;
 
        dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC;
        cmdsts = REAL_RX_BUF_SIZE | CMDSTS_INTR;
-       buf = pci_map_single(dev->pci_dev, skb->tail,
+       buf = pci_map_single(dev->pci_dev, skb->data,
                             REAL_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
        build_rx_desc(dev, sg, 0, buf, cmdsts, 0);
        /* update link of previous rx */
@@ -583,7 +583,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
        return 0;
 }
 
-static inline int rx_refill(struct net_device *ndev, int gfp)
+static inline int rx_refill(struct net_device *ndev, gfp_t gfp)
 {
        struct ns83820 *dev = PRIV(ndev);
        unsigned i;
@@ -603,7 +603,7 @@ static inline int rx_refill(struct net_device *ndev, int gfp)
                if (unlikely(!skb))
                        break;
 
-               res = (long)skb->tail & 0xf;
+               res = (long)skb->data & 0xf;
                res = 0x10 - res;
                res &= 0xf;
                skb_reserve(skb, res);
@@ -651,7 +651,7 @@ static void FASTCALL(phy_intr(struct net_device *ndev));
 static void fastcall phy_intr(struct net_device *ndev)
 {
        struct ns83820 *dev = PRIV(ndev);
-       static char *speeds[] = { "10", "100", "1000", "1000(?)", "1000F" };
+       static const char *speeds[] = { "10", "100", "1000", "1000(?)", "1000F" };
        u32 cfg, new_cfg;
        u32 tbisr, tanar, tanlpar;
        int speed, fullduplex, newlinkstate;
@@ -1557,15 +1557,13 @@ static void ns83820_getmac(struct ns83820 *dev, u8 *mac)
        unsigned i;
        for (i=0; i<3; i++) {
                u32 data;
-#if 0  /* I've left this in as an example of how to use eeprom.h */
-               data = eeprom_readw(&dev->ee, 0xa + 2 - i);
-#else
+
                /* Read from the perfect match memory: this is loaded by
                 * the chip from the EEPROM via the EELOAD self test.
                 */
                writel(i*2, dev->base + RFCR);
                data = readl(dev->base + RFDR);
-#endif
+
                *mac++ = data;
                *mac++ = data >> 8;
        }
@@ -1609,7 +1607,7 @@ static void ns83820_run_bist(struct net_device *ndev, const char *name, u32 enab
 {
        struct ns83820 *dev = PRIV(ndev);
        int timed_out = 0;
-       long start;
+       unsigned long start;
        u32 status;
        int loops = 0;
 
@@ -1627,12 +1625,11 @@ static void ns83820_run_bist(struct net_device *ndev, const char *name, u32 enab
                        break;
                if (status & fail)
                        break;
-               if ((jiffies - start) >= HZ) {
+               if (time_after_eq(jiffies, start + HZ)) {
                        timed_out = 1;
                        break;
                }
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_uninterruptible(1);
        }
 
        if (status & fail)
@@ -1830,10 +1827,10 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
        int using_dac = 0;
 
        /* See if we can set the dma mask early on; failure is fatal. */
-       if (sizeof(dma_addr_t) == 8 && 
-               !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) {
+       if (sizeof(dma_addr_t) == 8 &&
+               !pci_set_dma_mask(pci_dev, DMA_64BIT_MASK)) {
                using_dac = 1;
-       } else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) {
+       } else if (!pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) {
                using_dac = 0;
        } else {
                printk(KERN_WARNING "ns83820.c: pci_set_dma_mask failed!\n");
@@ -1851,8 +1848,6 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
        spin_lock_init(&dev->misc_lock);
        dev->pci_dev = pci_dev;
 
-       dev->ee.cache = &dev->MEAR_cache;
-       dev->ee.lock = &dev->misc_lock;
        SET_MODULE_OWNER(ndev);
        SET_NETDEV_DEV(ndev, &pci_dev->dev);
 
@@ -1887,9 +1882,6 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
 
        dev->IMR_cache = 0;
 
-       setup_ee_mem_bitbanger(&dev->ee, dev->base + MEAR, 3, 2, 1, 0,
-               0);
-
        err = request_irq(pci_dev->irq, ns83820_irq, SA_SHIRQ,
                          DRV_NAME, ndev);
        if (err) {
@@ -2195,6 +2187,7 @@ static void __exit ns83820_exit(void)
 MODULE_AUTHOR("Benjamin LaHaise <bcrl@kvack.org>");
 MODULE_DESCRIPTION("National Semiconductor DP83820 10/100/1000 driver");
 MODULE_LICENSE("GPL");
+MODULE_VERSION(VERSION);
 
 MODULE_DEVICE_TABLE(pci, ns83820_pci_tbl);