b43legacy: fix DMA slot resource leakage
[safe/jmp/linux-2.6] / drivers / net / tulip / winbond-840.c
index b54378f..35d0cfc 100644 (file)
@@ -45,8 +45,8 @@
 */
 
 #define DRV_NAME       "winbond-840"
-#define DRV_VERSION    "1.01-d"
-#define DRV_RELDATE    "Nov-17-2001"
+#define DRV_VERSION    "1.01-e"
+#define DRV_RELDATE    "Sep-11-2006"
 
 
 /* Automatically extracted configuration info:
@@ -332,14 +332,14 @@ static void tx_timeout(struct net_device *dev);
 static int alloc_ringdesc(struct net_device *dev);
 static void free_ringdesc(struct netdev_private *np);
 static int  start_tx(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t intr_handler(int irq, void *dev_instance);
 static void netdev_error(struct net_device *dev, int intr_status);
 static int  netdev_rx(struct net_device *dev);
 static u32 __set_rx_mode(struct net_device *dev);
 static void set_rx_mode(struct net_device *dev);
 static struct net_device_stats *get_stats(struct net_device *dev);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static struct ethtool_ops netdev_ethtool_ops;
+static const struct ethtool_ops netdev_ethtool_ops;
 static int  netdev_close(struct net_device *dev);
 
 
@@ -354,6 +354,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        int irq;
        int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
        void __iomem *ioaddr;
+       DECLARE_MAC_BUF(mac);
 
        i = pci_enable_device(pdev);
        if (i) return i;
@@ -370,7 +371,6 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        dev = alloc_etherdev(sizeof(*np));
        if (!dev)
                return -ENOMEM;
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        if (pci_request_regions(pdev, DRV_NAME))
@@ -381,7 +381,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
                goto err_out_free_res;
 
        for (i = 0; i < 3; i++)
-               ((u16 *)dev->dev_addr)[i] = le16_to_cpu(eeprom_read(ioaddr, i));
+               ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(eeprom_read(ioaddr, i));
 
        /* Reset the chip to erase previous misconfiguration.
           No hold time required! */
@@ -434,11 +434,9 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        if (i)
                goto err_out_cleardev;
 
-       printk(KERN_INFO "%s: %s at %p, ",
-                  dev->name, pci_id_tbl[chip_idx].name, ioaddr);
-       for (i = 0; i < 5; i++)
-                       printk("%2.2x:", dev->dev_addr[i]);
-       printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
+       printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n",
+              dev->name, pci_id_tbl[chip_idx].name, ioaddr,
+              print_mac(mac, dev->dev_addr), irq);
 
        if (np->drv_flags & CanHaveMII) {
                int phy, phy_idx = 0;
@@ -485,7 +483,7 @@ err_out_netdev:
    a delay.  Note that pre-2.0.34 kernels had a cache-alignment bug that
    made udelay() unreliable.
    The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
-   depricated.
+   deprecated.
 */
 #define eeprom_delay(ee_addr)  ioread32(ee_addr)
 
@@ -813,7 +811,6 @@ static void init_rxtx_rings(struct net_device *dev)
                np->rx_skbuff[i] = skb;
                if (skb == NULL)
                        break;
-               skb->dev = dev;                 /* Mark as being used by this device. */
                np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data,
                                        np->rx_buf_sz,PCI_DMA_FROMDEVICE);
 
@@ -903,7 +900,7 @@ static void init_registers(struct net_device *dev)
        }
 #elif defined(__powerpc__) || defined(__i386__) || defined(__alpha__) || defined(__ia64__) || defined(__x86_64__)
        i |= 0xE000;
-#elif defined(__sparc__) || defined (CONFIG_PARISC)
+#elif defined(CONFIG_SPARC) || defined (CONFIG_PARISC)
        i |= 0x4800;
 #else
 #warning Processor architecture undefined
@@ -1022,7 +1019,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
                np->tx_ring[entry].length |= DescEndRing;
 
        /* Now acquire the irq spinlock.
-        * The difficult race is the the ordering between
+        * The difficult race is the ordering between
         * increasing np->cur_tx and setting DescOwned:
         * - if np->cur_tx is increased first the interrupt
         *   handler could consider the packet as transmitted
@@ -1110,7 +1107,7 @@ static void netdev_tx_done(struct net_device *dev)
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance)
 {
        struct net_device *dev = (struct net_device *)dev_instance;
        struct netdev_private *np = netdev_priv(dev);
@@ -1148,7 +1145,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                }
 
                /* Abnormal error summary/uncommon events handlers. */
-               if (intr_status & (AbnormalIntr | TxFIFOUnderflow | SytemError |
+               if (intr_status & (AbnormalIntr | TxFIFOUnderflow | SystemError |
                                                   TimerInt | TxDied))
                        netdev_error(dev, intr_status);
 
@@ -1229,12 +1226,11 @@ static int netdev_rx(struct net_device *dev)
                           to a minimally-sized skbuff. */
                        if (pkt_len < rx_copybreak
                                && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
-                               skb->dev = dev;
                                skb_reserve(skb, 2);    /* 16 byte align the IP header */
                                pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry],
                                                            np->rx_skbuff[entry]->len,
                                                            PCI_DMA_FROMDEVICE);
-                               eth_copy_and_sum(skb, np->rx_skbuff[entry]->data, pkt_len, 0);
+                               skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len);
                                skb_put(skb, pkt_len);
                                pci_dma_sync_single_for_device(np->pci_dev,np->rx_addr[entry],
                                                               np->rx_skbuff[entry]->len,
@@ -1248,16 +1244,16 @@ static int netdev_rx(struct net_device *dev)
                        }
 #ifndef final_version                          /* Remove after testing. */
                        /* You will want this info for the initial debug. */
-                       if (debug > 5)
-                               printk(KERN_DEBUG "  Rx data %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:"
-                                          "%2.2x %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x %2.2x%2.2x "
-                                          "%d.%d.%d.%d.\n",
-                                          skb->data[0], skb->data[1], skb->data[2], skb->data[3],
-                                          skb->data[4], skb->data[5], skb->data[6], skb->data[7],
-                                          skb->data[8], skb->data[9], skb->data[10],
-                                          skb->data[11], skb->data[12], skb->data[13],
-                                          skb->data[14], skb->data[15], skb->data[16],
-                                          skb->data[17]);
+                       if (debug > 5) {
+                               DECLARE_MAC_BUF(mac);
+                               DECLARE_MAC_BUF(mac2);
+
+                               printk(KERN_DEBUG "  Rx data %s %s"
+                                      " %2.2x%2.2x %d.%d.%d.%d.\n",
+                                      print_mac(mac, &skb->data[0]), print_mac(mac2, &skb->data[6]),
+                                      skb->data[12], skb->data[13],
+                                      skb->data[14], skb->data[15], skb->data[16], skb->data[17]);
+                       }
 #endif
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
@@ -1278,7 +1274,6 @@ static int netdev_rx(struct net_device *dev)
                        np->rx_skbuff[entry] = skb;
                        if (skb == NULL)
                                break;                  /* Better luck next round. */
-                       skb->dev = dev;                 /* Mark as being used by this device. */
                        np->rx_addr[entry] = pci_map_single(np->pci_dev,
                                                        skb->data,
                                                        np->rx_buf_sz, PCI_DMA_FROMDEVICE);
@@ -1358,8 +1353,6 @@ static u32 __set_rx_mode(struct net_device *dev)
        u32 rx_mode;
 
        if (dev->flags & IFF_PROMISC) {                 /* Set promiscuous. */
-               /* Unconditionally log net taps. */
-               printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
                memset(mc_filter, 0xff, sizeof(mc_filter));
                rx_mode = RxAcceptBroadcast | AcceptMulticast | RxAcceptAllPhys
                        | AcceptMyPhys;
@@ -1449,7 +1442,7 @@ static void netdev_set_msglevel(struct net_device *dev, u32 value)
        debug = value;
 }
 
-static struct ethtool_ops netdev_ethtool_ops = {
+static const struct ethtool_ops netdev_ethtool_ops = {
        .get_drvinfo            = netdev_get_drvinfo,
        .get_settings           = netdev_get_settings,
        .set_settings           = netdev_set_settings,
@@ -1457,8 +1450,6 @@ static struct ethtool_ops netdev_ethtool_ops = {
        .get_link               = netdev_get_link,
        .get_msglevel           = netdev_get_msglevel,
        .set_msglevel           = netdev_set_msglevel,
-       .get_sg                 = ethtool_op_get_sg,
-       .get_tx_csum            = ethtool_op_get_tx_csum,
 };
 
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1604,7 +1595,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
 
                synchronize_irq(dev->irq);
                netif_tx_disable(dev);
-       
+
                np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
 
                /* no more hardware accesses behind this line. */
@@ -1626,14 +1617,18 @@ static int w840_resume (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
        struct netdev_private *np = netdev_priv(dev);
+       int retval = 0;
 
        rtnl_lock();
        if (netif_device_present(dev))
                goto out; /* device not suspended */
        if (netif_running(dev)) {
-               pci_enable_device(pdev);
-       /*      pci_power_on(pdev); */
-
+               if ((retval = pci_enable_device(pdev))) {
+                       printk (KERN_ERR
+                               "%s: pci_enable_device failed in resume\n",
+                               dev->name);
+                       goto out;
+               }
                spin_lock_irq(&np->lock);
                iowrite32(1, np->base_addr+PCIBusCfg);
                ioread32(np->base_addr+PCIBusCfg);
@@ -1651,7 +1646,7 @@ static int w840_resume (struct pci_dev *pdev)
        }
 out:
        rtnl_unlock();
-       return 0;
+       return retval;
 }
 #endif