drivers/net/: use DEFINE_PCI_DEVICE_TABLE()
[safe/jmp/linux-2.6] / drivers / net / tulip / uli526x.c
index 00cbc52..d549042 100644 (file)
@@ -168,9 +168,6 @@ struct uli526x_board_info {
        u8 wait_reset;                  /* Hardware failed, need to reset */
        struct timer_list timer;
 
-       /* System defined statistic counter */
-       struct net_device_stats stats;
-
        /* Driver defined statistic counter */
        unsigned long tx_fifo_underrun;
        unsigned long tx_loss_carrier;
@@ -203,7 +200,7 @@ enum uli526x_CR6_bits {
 
 /* Global variable declaration ----------------------------- */
 static int __devinitdata printed_version;
-static char version[] __devinitdata =
+static const char version[] __devinitconst =
        KERN_INFO DRV_NAME ": ULi M5261/M5263 net driver, version "
        DRV_VERSION " (" DRV_RELDATE ")\n";
 
@@ -218,9 +215,9 @@ static int mode = 8;
 
 /* function declaration ------------------------------------- */
 static int uli526x_open(struct net_device *);
-static int uli526x_start_xmit(struct sk_buff *, struct net_device *);
+static netdev_tx_t uli526x_start_xmit(struct sk_buff *,
+                                           struct net_device *);
 static int uli526x_stop(struct net_device *);
-static struct net_device_stats * uli526x_get_stats(struct net_device *);
 static void uli526x_set_filter_mode(struct net_device *);
 static const struct ethtool_ops netdev_ethtool_ops;
 static u16 read_srom_word(long, int);
@@ -251,6 +248,19 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *);
 
 /* ULI526X network board routine ---------------------------- */
 
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = uli526x_open,
+       .ndo_stop               = uli526x_stop,
+       .ndo_start_xmit         = uli526x_start_xmit,
+       .ndo_set_multicast_list = uli526x_set_filter_mode,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = uli526x_poll,
+#endif
+};
+
 /*
  *     Search ULI526X board, allocate space and register it
  */
@@ -273,7 +283,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
                return -ENOMEM;
        SET_NETDEV_DEV(dev, &pdev->dev);
 
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                printk(KERN_WARNING DRV_NAME ": 32-bit PCI DMA not available.\n");
                err = -ENODEV;
                goto err_out_free;
@@ -335,15 +345,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
        pci_set_drvdata(pdev, dev);
 
        /* Register some necessary functions */
-       dev->open = &uli526x_open;
-       dev->hard_start_xmit = &uli526x_start_xmit;
-       dev->stop = &uli526x_stop;
-       dev->get_stats = &uli526x_get_stats;
-       dev->set_multicast_list = &uli526x_set_filter_mode;
+       dev->netdev_ops = &netdev_ops;
        dev->ethtool_ops = &netdev_ethtool_ops;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = &uli526x_poll;
-#endif
+
        spin_lock_init(&db->lock);
 
 
@@ -457,7 +461,7 @@ static int uli526x_open(struct net_device *dev)
        /* Initialize ULI526X board */
        uli526x_init(dev);
 
-       ret = request_irq(dev->irq, &uli526x_interrupt, IRQF_SHARED, dev->name, dev);
+       ret = request_irq(dev->irq, uli526x_interrupt, IRQF_SHARED, dev->name, dev);
        if (ret)
                return ret;
 
@@ -564,7 +568,8 @@ static void uli526x_init(struct net_device *dev)
  *     Send a packet to media from the upper layer.
  */
 
-static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t uli526x_start_xmit(struct sk_buff *skb,
+                                           struct net_device *dev)
 {
        struct uli526x_board_info *db = netdev_priv(dev);
        struct tx_desc *txptr;
@@ -579,7 +584,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (skb->len > MAX_PACKET_SIZE) {
                printk(KERN_ERR DRV_NAME ": big packet = %d\n", (u16)skb->len);
                dev_kfree_skb(skb);
-               return 0;
+               return NETDEV_TX_OK;
        }
 
        spin_lock_irqsave(&db->lock, flags);
@@ -588,7 +593,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (db->tx_packet_cnt >= TX_FREE_DESC_CNT) {
                spin_unlock_irqrestore(&db->lock, flags);
                printk(KERN_ERR DRV_NAME ": No Tx resource %ld\n", db->tx_packet_cnt);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        /* Disable NIC interrupt */
@@ -621,7 +626,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev)
        /* free this SKB */
        dev_kfree_skb(skb);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 
@@ -733,7 +738,8 @@ static void uli526x_poll(struct net_device *dev)
  *     Free TX resource after TX complete
  */
 
-static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_info * db)
+static void uli526x_free_tx_pkt(struct net_device *dev,
+                               struct uli526x_board_info * db)
 {
        struct tx_desc *txptr;
        u32 tdes0;
@@ -747,15 +753,15 @@ static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_inf
 
                /* A packet sent completed */
                db->tx_packet_cnt--;
-               db->stats.tx_packets++;
+               dev->stats.tx_packets++;
 
                /* Transmit statistic counter */
                if ( tdes0 != 0x7fffffff ) {
                        /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */
-                       db->stats.collisions += (tdes0 >> 3) & 0xf;
-                       db->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff;
+                       dev->stats.collisions += (tdes0 >> 3) & 0xf;
+                       dev->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff;
                        if (tdes0 & TDES0_ERR_MASK) {
-                               db->stats.tx_errors++;
+                               dev->stats.tx_errors++;
                                if (tdes0 & 0x0002) {   /* UnderRun */
                                        db->tx_fifo_underrun++;
                                        if ( !(db->cr6_data & CR6_SFT) ) {
@@ -825,13 +831,13 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
                        if (rdes0 & 0x8000) {
                                /* This is a error packet */
                                //printk(DRV_NAME ": rdes0: %lx\n", rdes0);
-                               db->stats.rx_errors++;
+                               dev->stats.rx_errors++;
                                if (rdes0 & 1)
-                                       db->stats.rx_fifo_errors++;
+                                       dev->stats.rx_fifo_errors++;
                                if (rdes0 & 2)
-                                       db->stats.rx_crc_errors++;
+                                       dev->stats.rx_crc_errors++;
                                if (rdes0 & 0x80)
-                                       db->stats.rx_length_errors++;
+                                       dev->stats.rx_length_errors++;
                        }
 
                        if ( !(rdes0 & 0x8000) ||
@@ -854,8 +860,8 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
 
                                skb->protocol = eth_type_trans(skb, dev);
                                netif_rx(skb);
-                               db->stats.rx_packets++;
-                               db->stats.rx_bytes += rxlen;
+                               dev->stats.rx_packets++;
+                               dev->stats.rx_bytes += rxlen;
 
                        } else {
                                /* Reuse SKB buffer when the packet is error */
@@ -872,19 +878,6 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
 
 
 /*
- *     Get statistics from driver.
- */
-
-static struct net_device_stats * uli526x_get_stats(struct net_device *dev)
-{
-       struct uli526x_board_info *db = netdev_priv(dev);
-
-       ULI526X_DBUG(0, "uli526x_get_stats", 0);
-       return &db->stats;
-}
-
-
-/*
  * Set ULI526X multicast address
  */
 
@@ -1790,7 +1783,7 @@ static u16 phy_read_1bit(unsigned long ioaddr, u32 chip_id)
 }
 
 
-static struct pci_device_id uli526x_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(uli526x_pci_tbl) = {
        { 0x10B9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5261_ID },
        { 0x10B9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5263_ID },
        { 0, }