omap: i2c: add a timeout to the busy waiting
[safe/jmp/linux-2.6] / drivers / net / hp100.c
index 8feda9f..4daad8c 100644 (file)
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/eisa.h>
 #include <linux/pci.h>
@@ -209,7 +209,7 @@ MODULE_DEVICE_TABLE(eisa, hp100_eisa_tbl);
 #endif
 
 #ifdef CONFIG_PCI
-static struct pci_device_id hp100_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(hp100_pci_tbl) = {
        {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A, PCI_ANY_ID, PCI_ANY_ID,},
        {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B, PCI_ANY_ID, PCI_ANY_ID,},
        {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2970A, PCI_ANY_ID, PCI_ANY_ID,},
@@ -240,9 +240,10 @@ static int hp100_probe1(struct net_device *dev, int ioaddr, u_char bus,
 
 static int hp100_open(struct net_device *dev);
 static int hp100_close(struct net_device *dev);
-static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static int hp100_start_xmit_bm(struct sk_buff *skb,
-                              struct net_device *dev);
+static netdev_tx_t hp100_start_xmit(struct sk_buff *skb,
+                                   struct net_device *dev);
+static netdev_tx_t hp100_start_xmit_bm(struct sk_buff *skb,
+                                      struct net_device *dev);
 static void hp100_rx(struct net_device *dev);
 static struct net_device_stats *hp100_get_stats(struct net_device *dev);
 static void hp100_misc_interrupt(struct net_device *dev);
@@ -991,8 +992,8 @@ static void hp100_mmuinit(struct net_device *dev)
        if (lp->mode == 1) {    /* only needed for Busmaster */
                int xmit_stop, recv_stop;
 
-               if ((lp->chip == HP100_CHIPID_RAINIER)
-                   || (lp->chip == HP100_CHIPID_SHASTA)) {
+               if ((lp->chip == HP100_CHIPID_RAINIER) ||
+                   (lp->chip == HP100_CHIPID_SHASTA)) {
                        int pdl_stop;
 
                        /*
@@ -1483,7 +1484,8 @@ static int hp100_check_lan(struct net_device *dev)
  */
 
 /* tx function for busmaster mode */
-static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t hp100_start_xmit_bm(struct sk_buff *skb,
+                                      struct net_device *dev)
 {
        unsigned long flags;
        int i, ok_flag;
@@ -1495,16 +1497,11 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
        hp100_outw(0x4210, TRACE);
        printk("hp100: %s: start_xmit_bm\n", dev->name);
 #endif
-
-       if (skb == NULL) {
-               return 0;
-       }
-
        if (skb->len <= 0)
-               return 0;
+               goto drop;
 
        if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN))
-               return 0;
+               return NETDEV_TX_OK;
 
        /* Get Tx ring tail pointer */
        if (lp->txrtail->next == lp->txrhead) {
@@ -1514,10 +1511,10 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
 #endif
                /* not waited long enough since last tx? */
                if (time_before(jiffies, dev->trans_start + HZ))
-                       return -EAGAIN;
+                       goto drop;
 
                if (hp100_check_lan(dev))
-                       return -EIO;
+                       goto drop;
 
                if (lp->lan_type == HP100_LAN_100 && lp->hub_status < 0) {
                        /* we have a 100Mb/s adapter but it isn't connected to hub */
@@ -1551,7 +1548,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
                }
 
                dev->trans_start = jiffies;
-               return -EAGAIN;
+               goto drop;
        }
 
        /*
@@ -1590,7 +1587,11 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
        lp->stats.tx_bytes += skb->len;
        dev->trans_start = jiffies;
 
-       return 0;
+       return NETDEV_TX_OK;
+
+drop:
+       dev_kfree_skb(skb);
+       return NETDEV_TX_OK;
 }
 
 
@@ -1636,7 +1637,8 @@ static void hp100_clean_txring(struct net_device *dev)
 }
 
 /* tx function for slave modes */
-static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t hp100_start_xmit(struct sk_buff *skb,
+                                   struct net_device *dev)
 {
        unsigned long flags;
        int i, ok_flag;
@@ -1648,16 +1650,11 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
        hp100_outw(0x4212, TRACE);
        printk("hp100: %s: start_xmit\n", dev->name);
 #endif
-
-       if (skb == NULL) {
-               return 0;
-       }
-
        if (skb->len <= 0)
-               return 0;
+               goto drop;
 
        if (hp100_check_lan(dev))
-               return -EIO;
+               goto drop;
 
        /* If there is not enough free memory on the card... */
        i = hp100_inl(TX_MEM_FREE) & 0x7fffffff;
@@ -1671,7 +1668,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        printk("hp100: %s: trans_start timing problem\n",
                               dev->name);
 #endif
-                       return -EAGAIN;
+                       goto drop;
                }
                if (lp->lan_type == HP100_LAN_100 && lp->hub_status < 0) {
                        /* we have a 100Mb/s adapter but it isn't connected to hub */
@@ -1705,7 +1702,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        }
                }
                dev->trans_start = jiffies;
-               return -EAGAIN;
+               goto drop;
        }
 
        for (i = 0; i < 6000 && (hp100_inb(OPTION_MSW) & HP100_TX_CMD); i++) {
@@ -1758,7 +1755,12 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
        printk("hp100: %s: start_xmit: end\n", dev->name);
 #endif
 
-       return 0;
+       return NETDEV_TX_OK;
+
+drop:
+       dev_kfree_skb(skb);
+       return NETDEV_TX_OK;
+
 }
 
 
@@ -2087,7 +2089,7 @@ static void hp100_set_multicast_list(struct net_device *dev)
                lp->mac2_mode = HP100_MAC2MODE6;        /* promiscuous mode = get all good */
                lp->mac1_mode = HP100_MAC1MODE6;        /* packets on the net */
                memset(&lp->hash_bytes, 0xff, 8);
-       } else if (dev->mc_count || (dev->flags & IFF_ALLMULTI)) {
+       } else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) {
                lp->mac2_mode = HP100_MAC2MODE5;        /* multicast mode = get packets for */
                lp->mac1_mode = HP100_MAC1MODE5;        /* me, broadcasts and all multicasts */
 #ifdef HP100_MULTICAST_FILTER  /* doesn't work!!! */
@@ -2095,22 +2097,23 @@ static void hp100_set_multicast_list(struct net_device *dev)
                        /* set hash filter to receive all multicast packets */
                        memset(&lp->hash_bytes, 0xff, 8);
                } else {
-                       int i, j, idx;
+                       int i, idx;
                        u_char *addrs;
                        struct dev_mc_list *dmi;
 
                        memset(&lp->hash_bytes, 0x00, 8);
 #ifdef HP100_DEBUG
-                       printk("hp100: %s: computing hash filter - mc_count = %i\n", dev->name, dev->mc_count);
+                       printk("hp100: %s: computing hash filter - mc_count = %i\n",
+                              dev->name, netdev_mc_count(dev));
 #endif
-                       for (i = 0, dmi = dev->mc_list; i < dev->mc_count; i++, dmi = dmi->next) {
+                       netdev_for_each_mc_addr(dmi, dev) {
                                addrs = dmi->dmi_addr;
                                if ((*addrs & 0x01) == 0x01) {  /* multicast address? */
 #ifdef HP100_DEBUG
                                        printk("hp100: %s: multicast = %pM, ",
                                                     dev->name, addrs);
 #endif
-                                       for (j = idx = 0; j < 6; j++) {
+                                       for (i = idx = 0; i < 6; i++) {
                                                idx ^= *addrs++ & 0x3f;
                                                printk(":%02x:", idx);
                                        }