iwlwifi: Add chain noise scaling factor
[safe/jmp/linux-2.6] / drivers / net / hp100.c
index 571dd80..90f890e 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) {
@@ -975,8 +993,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;
 
                        /*
@@ -1212,7 +1230,7 @@ static int hp100_init_rxpdl(struct net_device *dev,
        *(pdlptr + 2) = (u_int) virt_to_whatever(dev, pdlptr);  /* Address Frag 1 */
        *(pdlptr + 3) = 4;      /* Length  Frag 1 */
 
-       return ((((MAX_RX_FRAG * 2 + 2) + 3) / 4) * 4);
+       return roundup(MAX_RX_FRAG * 2 + 2, 4);
 }
 
 
@@ -1227,7 +1245,7 @@ static int hp100_init_txpdl(struct net_device *dev,
        ringptr->pdl_paddr = virt_to_whatever(dev, pdlptr);     /* +1 */
        ringptr->skb = (void *) NULL;
 
-       return ((((MAX_TX_FRAG * 2 + 2) + 3) / 4) * 4);
+       return roundup(MAX_TX_FRAG * 2 + 2, 4);
 }
 
 /*
@@ -1256,7 +1274,7 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr,
        /* Note: This depends on the alloc_skb functions allocating more
         * space than requested, i.e. aligning to 16bytes */
 
-       ringptr->skb = dev_alloc_skb(((MAX_ETHER_SIZE + 2 + 3) / 4) * 4);
+       ringptr->skb = dev_alloc_skb(roundup(MAX_ETHER_SIZE + 2, 4));
 
        if (NULL != ringptr->skb) {
                /*
@@ -1279,7 +1297,7 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr,
 #ifdef HP100_DEBUG_BM
                printk("hp100: %s: build_rx_pdl: PDH@0x%x, skb->data (len %d) at 0x%x\n",
                                     dev->name, (u_int) ringptr->pdl,
-                                    ((MAX_ETHER_SIZE + 2 + 3) / 4) * 4,
+                                    roundup(MAX_ETHER_SIZE + 2, 4),
                                     (unsigned int) ringptr->skb->data);
 #endif
 
@@ -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;
+
 }
 
 
@@ -1834,7 +1853,6 @@ static void hp100_rx(struct net_device *dev)
                                        ptr[9], ptr[10], ptr[11]);
 #endif
                        netif_rx(skb);
-                       dev->last_rx = jiffies;
                        lp->stats.rx_packets++;
                        lp->stats.rx_bytes += pkt_len;
                }
@@ -1925,7 +1943,6 @@ static void hp100_rx_bm(struct net_device *dev)
 
                                netif_rx(ptr->skb);     /* Up and away... */
 
-                               dev->last_rx = jiffies;
                                lp->stats.rx_packets++;
                                lp->stats.rx_bytes += pkt_len;
                        }
@@ -2093,9 +2110,8 @@ static void hp100_set_multicast_list(struct net_device *dev)
                                addrs = dmi->dmi_addr;
                                if ((*addrs & 0x01) == 0x01) {  /* multicast address? */
 #ifdef HP100_DEBUG
-                                       DECLARE_MAC_BUF(mac);
-                                       printk("hp100: %s: multicast = %s, ",
-                                                    dev->name, print_mac(mac, addrs));
+                                       printk("hp100: %s: multicast = %pM, ",
+                                                    dev->name, addrs);
 #endif
                                        for (j = idx = 0; j < 6; j++) {
                                                idx ^= *addrs++ & 0x3f;
@@ -2851,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);
@@ -2860,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;
 }
@@ -3057,12 +3073,3 @@ static void __exit hp100_module_exit(void)
 
 module_init(hp100_module_init)
 module_exit(hp100_module_exit)
-
-
-/*
- * Local variables:
- *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c hp100.c"
- *  c-indent-level: 2
- *  tab-width: 8
- * End:
- */