drivers/video/msm: update to new kernel
[safe/jmp/linux-2.6] / drivers / net / hp100.c
index ebe7651..dd86651 100644 (file)
@@ -98,6 +98,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
@@ -240,9 +241,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);
@@ -425,6 +427,28 @@ struct net_device * __init hp100_probe(int unit)
 }
 #endif /* !MODULE && CONFIG_ISA */
 
+static const struct net_device_ops hp100_bm_netdev_ops = {
+       .ndo_open               = hp100_open,
+       .ndo_stop               = hp100_close,
+       .ndo_start_xmit         = hp100_start_xmit_bm,
+       .ndo_get_stats          = hp100_get_stats,
+       .ndo_set_multicast_list = hp100_set_multicast_list,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
+static const struct net_device_ops hp100_netdev_ops = {
+       .ndo_open               = hp100_open,
+       .ndo_stop               = hp100_close,
+       .ndo_start_xmit         = hp100_start_xmit,
+       .ndo_get_stats          = hp100_get_stats,
+       .ndo_set_multicast_list = hp100_set_multicast_list,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
                                  u_char bus, struct pci_dev *pci_dev)
 {
@@ -558,7 +582,7 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
                         * Also, we can have EISA Busmaster cards (not tested),
                         * so beware !!! - Jean II */
                        if((bus == HP100_BUS_PCI) &&
-                          (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK))) {
+                          (pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32)))) {
                                /* Gracefully fallback to shared memory */
                                goto busmasterfail;
                        }
@@ -657,16 +681,10 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
        lp->virt_memory_size = virt_memory_size;
        lp->rx_ratio = hp100_rx_ratio;  /* can be conf'd with insmod */
 
-       dev->open = hp100_open;
-       dev->stop = hp100_close;
-
        if (lp->mode == 1)      /* busmaster */
-               dev->hard_start_xmit = hp100_start_xmit_bm;
+               dev->netdev_ops = &hp100_bm_netdev_ops;
        else
-               dev->hard_start_xmit = hp100_start_xmit;
-
-       dev->get_stats = hp100_get_stats;
-       dev->set_multicast_list = &hp100_set_multicast_list;
+               dev->netdev_ops = &hp100_netdev_ops;
 
        /* Ask the card for which IRQ line it is configured */
        if (bus == HP100_BUS_PCI) {
@@ -1467,7 +1485,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;
@@ -1479,16 +1498,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) {
@@ -1498,10 +1512,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 */
@@ -1535,7 +1549,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
                }
 
                dev->trans_start = jiffies;
-               return -EAGAIN;
+               goto drop;
        }
 
        /*
@@ -1574,7 +1588,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;
 }
 
 
@@ -1620,7 +1638,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;
@@ -1632,16 +1651,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;
@@ -1655,7 +1669,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 */
@@ -1689,7 +1703,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++) {
@@ -1742,7 +1756,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;
+
 }
 
 
@@ -2848,7 +2867,7 @@ static int __init hp100_eisa_probe (struct device *gendev)
        printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name,
               dev->base_addr);
 #endif
-       gendev->driver_data = dev;
+       dev_set_drvdata(gendev, dev);
        return 0;
  out1:
        free_netdev(dev);
@@ -2857,7 +2876,7 @@ static int __init hp100_eisa_probe (struct device *gendev)
 
 static int __devexit hp100_eisa_remove (struct device *gendev)
 {
-       struct net_device *dev = gendev->driver_data;
+       struct net_device *dev = dev_get_drvdata(gendev);
        cleanup_dev(dev);
        return 0;
 }