headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / net / ns83820.c
index 4bb6441..57fd483 100644 (file)
 #include <linux/compiler.h>
 #include <linux/prefetch.h>
 #include <linux/ethtool.h>
+#include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/if_vlan.h>
 #include <linux/rtnetlink.h>
@@ -409,7 +410,7 @@ static int lnksts = 0;              /* CFG_LNKSTS bit polarity */
 struct rx_info {
        spinlock_t      lock;
        int             up;
-       long            idle;
+       unsigned long   idle;
 
        struct sk_buff  *skbs[NR_RX_DESC];
 
@@ -822,8 +823,7 @@ static void ns83820_cleanup_rx(struct ns83820 *dev)
                struct sk_buff *skb = dev->rx_info.skbs[i];
                dev->rx_info.skbs[i] = NULL;
                clear_rx_desc(dev, i);
-               if (skb)
-                       kfree_skb(skb);
+               kfree_skb(skb);
        }
 }
 
@@ -1078,7 +1078,8 @@ static void ns83820_cleanup_tx(struct ns83820 *dev)
  * while trying to track down a bug in either the zero copy code or
  * the tx fifo (hence the MAX_FRAG_LEN).
  */
-static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+static netdev_tx_t ns83820_hard_start_xmit(struct sk_buff *skb,
+                                          struct net_device *ndev)
 {
        struct ns83820 *dev = PRIV(ndev);
        u32 free_idx, cmdsts, extsts;
@@ -1098,7 +1099,7 @@ again:
        if (unlikely(dev->CFG_cache & CFG_LNKSTS)) {
                netif_stop_queue(ndev);
                if (unlikely(dev->CFG_cache & CFG_LNKSTS))
-                       return 1;
+                       return NETDEV_TX_BUSY;
                netif_start_queue(ndev);
        }
 
@@ -1116,7 +1117,7 @@ again:
                        netif_start_queue(ndev);
                        goto again;
                }
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        if (free_idx == dev->tx_intr_idx) {
@@ -1205,9 +1206,7 @@ again:
        if (stopped && (dev->tx_done_idx != tx_done_idx) && start_tx_okay(dev))
                netif_start_queue(ndev);
 
-       /* set the transmit start time to catch transmit timeouts */
-       ndev->trans_start = jiffies;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void ns83820_update_stats(struct ns83820 *dev)
@@ -1627,7 +1626,7 @@ static void ns83820_tx_watch(unsigned long data)
                );
 #endif
 
-       if (time_after(jiffies, ndev->trans_start + 1*HZ) &&
+       if (time_after(jiffies, dev_trans_start(ndev) + 1*HZ) &&
            dev->tx_done_idx != dev->tx_free_idx) {
                printk(KERN_DEBUG "%s: ns83820_tx_watch: %u %u %d\n",
                        ndev->name,
@@ -1948,7 +1947,23 @@ static void ns83820_probe_phy(struct net_device *ndev)
 }
 #endif
 
-static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_device_id *id)
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = ns83820_open,
+       .ndo_stop               = ns83820_stop,
+       .ndo_start_xmit         = ns83820_hard_start_xmit,
+       .ndo_get_stats          = ns83820_get_stats,
+       .ndo_change_mtu         = ns83820_change_mtu,
+       .ndo_set_multicast_list = ns83820_set_multicast,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_tx_timeout         = ns83820_tx_timeout,
+#ifdef NS83820_VLAN_ACCEL_SUPPORT
+       .ndo_vlan_rx_register   = ns83820_vlan_rx_register,
+#endif
+};
+
+static int __devinit ns83820_init_one(struct pci_dev *pci_dev,
+                                     const struct pci_device_id *id)
 {
        struct net_device *ndev;
        struct ns83820 *dev;
@@ -1958,9 +1973,9 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
 
        /* 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, DMA_64BIT_MASK)) {
+               !pci_set_dma_mask(pci_dev, DMA_BIT_MASK(64))) {
                using_dac = 1;
-       } else if (!pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) {
+       } else if (!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) {
                using_dac = 0;
        } else {
                dev_warn(&pci_dev->dev, "pci_set_dma_mask failed!\n");
@@ -2040,14 +2055,8 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
                ndev->name, le32_to_cpu(readl(dev->base + 0x22c)),
                pci_dev->subsystem_vendor, pci_dev->subsystem_device);
 
-       ndev->open = ns83820_open;
-       ndev->stop = ns83820_stop;
-       ndev->hard_start_xmit = ns83820_hard_start_xmit;
-       ndev->get_stats = ns83820_get_stats;
-       ndev->change_mtu = ns83820_change_mtu;
-       ndev->set_multicast_list = ns83820_set_multicast;
+       ndev->netdev_ops = &netdev_ops;
        SET_ETHTOOL_OPS(ndev, &ops);
-       ndev->tx_timeout = ns83820_tx_timeout;
        ndev->watchdog_timeo = 5 * HZ;
        pci_set_drvdata(pci_dev, ndev);
 
@@ -2210,7 +2219,6 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
 #ifdef NS83820_VLAN_ACCEL_SUPPORT
        /* We also support hardware vlan acceleration */
        ndev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
-       ndev->vlan_rx_register = ns83820_vlan_rx_register;
 #endif
 
        if (using_dac) {