]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tc35815.c
tc35815: Use managed pci iomap helper
[linux-2.6-omap-h63xx.git] / drivers / net / tc35815.c
index 370d329d15d91cb1b56955afe8888e89d1c1234d..60eff784d5e4c585dc16ecd314e1026e4934728d 100644 (file)
@@ -94,37 +94,37 @@ static struct tc35815_options {
  * Registers
  */
 struct tc35815_regs {
-       volatile __u32 DMA_Ctl;         /* 0x00 */
-       volatile __u32 TxFrmPtr;
-       volatile __u32 TxThrsh;
-       volatile __u32 TxPollCtr;
-       volatile __u32 BLFrmPtr;
-       volatile __u32 RxFragSize;
-       volatile __u32 Int_En;
-       volatile __u32 FDA_Bas;
-       volatile __u32 FDA_Lim;         /* 0x20 */
-       volatile __u32 Int_Src;
-       volatile __u32 unused0[2];
-       volatile __u32 PauseCnt;
-       volatile __u32 RemPauCnt;
-       volatile __u32 TxCtlFrmStat;
-       volatile __u32 unused1;
-       volatile __u32 MAC_Ctl;         /* 0x40 */
-       volatile __u32 CAM_Ctl;
-       volatile __u32 Tx_Ctl;
-       volatile __u32 Tx_Stat;
-       volatile __u32 Rx_Ctl;
-       volatile __u32 Rx_Stat;
-       volatile __u32 MD_Data;
-       volatile __u32 MD_CA;
-       volatile __u32 CAM_Adr;         /* 0x60 */
-       volatile __u32 CAM_Data;
-       volatile __u32 CAM_Ena;
-       volatile __u32 PROM_Ctl;
-       volatile __u32 PROM_Data;
-       volatile __u32 Algn_Cnt;
-       volatile __u32 CRC_Cnt;
-       volatile __u32 Miss_Cnt;
+       __u32 DMA_Ctl;          /* 0x00 */
+       __u32 TxFrmPtr;
+       __u32 TxThrsh;
+       __u32 TxPollCtr;
+       __u32 BLFrmPtr;
+       __u32 RxFragSize;
+       __u32 Int_En;
+       __u32 FDA_Bas;
+       __u32 FDA_Lim;          /* 0x20 */
+       __u32 Int_Src;
+       __u32 unused0[2];
+       __u32 PauseCnt;
+       __u32 RemPauCnt;
+       __u32 TxCtlFrmStat;
+       __u32 unused1;
+       __u32 MAC_Ctl;          /* 0x40 */
+       __u32 CAM_Ctl;
+       __u32 Tx_Ctl;
+       __u32 Tx_Stat;
+       __u32 Rx_Ctl;
+       __u32 Rx_Stat;
+       __u32 MD_Data;
+       __u32 MD_CA;
+       __u32 CAM_Adr;          /* 0x60 */
+       __u32 CAM_Data;
+       __u32 CAM_Ena;
+       __u32 PROM_Ctl;
+       __u32 PROM_Data;
+       __u32 Algn_Cnt;
+       __u32 CRC_Cnt;
+       __u32 Miss_Cnt;
 };
 
 /*
@@ -396,8 +396,8 @@ struct FrFD {
 };
 
 
-#define tc_readl(addr) readl(addr)
-#define tc_writel(d, addr)     writel(d, addr)
+#define tc_readl(addr) ioread32(addr)
+#define tc_writel(d, addr)     iowrite32(d, addr)
 
 #define TC35815_TX_TIMEOUT  msecs_to_jiffies(400)
 
@@ -418,7 +418,6 @@ struct tc35815_local {
        struct napi_struct napi;
 
        /* statistics */
-       struct net_device_stats stats;
        struct {
                int max_tx_qlen;
                int tx_ints;
@@ -617,7 +616,7 @@ static int __devinit tc35815_mac_match(struct device *dev, void *data)
 
 static int __devinit tc35815_read_plat_dev_addr(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct device *pd = bus_find_device(&platform_bus_type, NULL,
                                            lp->pci_dev, tc35815_mac_match);
        if (pd) {
@@ -664,7 +663,7 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
        struct net_device *dev;
        struct tc35815_local *lp;
        int rc;
-       unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
+       DECLARE_MAC_BUF(mac);
 
        static int printed_version;
        if (!printed_version++) {
@@ -686,49 +685,18 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
                return -ENOMEM;
        }
        SET_NETDEV_DEV(dev, &pdev->dev);
-       lp = dev->priv;
+       lp = netdev_priv(dev);
        lp->dev = dev;
 
        /* enable device (incl. PCI PM wakeup), and bus-mastering */
-       rc = pci_enable_device (pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                goto err_out;
-
-       mmio_start = pci_resource_start (pdev, 1);
-       mmio_end = pci_resource_end (pdev, 1);
-       mmio_flags = pci_resource_flags (pdev, 1);
-       mmio_len = pci_resource_len (pdev, 1);
-
-       /* set this immediately, we need to know before
-        * we talk to the chip directly */
-
-       /* make sure PCI base addr 1 is MMIO */
-       if (!(mmio_flags & IORESOURCE_MEM)) {
-               dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
-               rc = -ENODEV;
-               goto err_out;
-       }
-
-       /* check for weird/broken PCI region reporting */
-       if ((mmio_len < sizeof(struct tc35815_regs))) {
-               dev_err(&pdev->dev, "Invalid PCI region size(s), aborting\n");
-               rc = -ENODEV;
-               goto err_out;
-       }
-
-       rc = pci_request_regions (pdev, MODNAME);
+       rc = pcim_iomap_regions(pdev, 1 << 1, MODNAME);
        if (rc)
                goto err_out;
-
-       pci_set_master (pdev);
-
-       /* ioremap MMIO region */
-       ioaddr = ioremap (mmio_start, mmio_len);
-       if (ioaddr == NULL) {
-               dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
-               rc = -EIO;
-               goto err_out_free_res;
-       }
+       pci_set_master(pdev);
+       ioaddr = pcim_iomap_table(pdev)[1];
 
        /* Initialize the device structure. */
        dev->open = tc35815_open;
@@ -768,18 +736,14 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
 
        rc = register_netdev (dev);
        if (rc)
-               goto err_out_unmap;
+               goto err_out;
 
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
-       printk(KERN_INFO "%s: %s at 0x%lx, "
-               "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
-               "IRQ %d\n",
+       printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n",
                dev->name,
                board_info[ent->driver_data].name,
                dev->base_addr,
-               dev->dev_addr[0], dev->dev_addr[1],
-               dev->dev_addr[2], dev->dev_addr[3],
-               dev->dev_addr[4], dev->dev_addr[5],
+               print_mac(mac, dev->dev_addr),
                dev->irq);
 
        setup_timer(&lp->timer, tc35815_timer, (unsigned long) dev);
@@ -795,10 +759,6 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
 
        return 0;
 
-err_out_unmap:
-       iounmap(ioaddr);
-err_out_free_res:
-       pci_release_regions (pdev);
 err_out:
        free_netdev (dev);
        return rc;
@@ -808,17 +768,8 @@ err_out:
 static void __devexit tc35815_remove_one (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
-       unsigned long mmio_addr;
-
-       mmio_addr = dev->base_addr;
 
        unregister_netdev (dev);
-
-       if (mmio_addr) {
-               iounmap ((void __iomem *)mmio_addr);
-               pci_release_regions (pdev);
-       }
-
        free_netdev (dev);
 
        pci_set_drvdata (pdev, NULL);
@@ -827,7 +778,7 @@ static void __devexit tc35815_remove_one (struct pci_dev *pdev)
 static int
 tc35815_init_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
        unsigned long fd_addr;
 
@@ -964,7 +915,7 @@ tc35815_init_queues(struct net_device *dev)
 static void
 tc35815_clear_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        for (i = 0; i < TX_FD_NUM; i++) {
@@ -995,7 +946,7 @@ tc35815_clear_queues(struct net_device *dev)
 static void
 tc35815_free_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        if (lp->tfd_base) {
@@ -1109,7 +1060,7 @@ dump_frfd(struct FrFD *fd)
 static void
 panic_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        printk("TxFD base %p, start %u, end %u\n",
@@ -1128,28 +1079,25 @@ panic_queues(struct net_device *dev)
 }
 #endif
 
-static void print_eth(char *add)
+static void print_eth(const u8 *add)
 {
-       int i;
+       DECLARE_MAC_BUF(mac);
 
-       printk("print_eth(%p)\n", add);
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i + 6]);
-       printk(" =>");
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i]);
-       printk(" : %2.2X%2.2X\n", (unsigned char) add[12], (unsigned char) add[13]);
+       printk(KERN_DEBUG "print_eth(%p)\n", add);
+       printk(KERN_DEBUG " %s =>", print_mac(mac, add + 6));
+       printk(KERN_CONT " %s : %02x%02x\n",
+               print_mac(mac, add), add[12], add[13]);
 }
 
 static int tc35815_tx_full(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        return ((lp->tfd_start + 1) % TX_FD_NUM == lp->tfd_end);
 }
 
 static void tc35815_restart(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        int do_phy_reset = 1;
        del_timer(&lp->timer);          /* Kill if running      */
@@ -1180,7 +1128,7 @@ static void tc35815_restart(struct net_device *dev)
 
 static void tc35815_tx_timeout(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
 
@@ -1192,7 +1140,7 @@ static void tc35815_tx_timeout(struct net_device *dev)
        tc35815_restart(dev);
        spin_unlock_irq(&lp->lock);
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
 
        /* If we have space available to accept new transmit
         * requests, wake up the queueing layer.  This would
@@ -1219,7 +1167,7 @@ static void tc35815_tx_timeout(struct net_device *dev)
 static int
 tc35815_open(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
 
        /*
         * This is used if the interrupt line can turned off (shared).
@@ -1261,7 +1209,7 @@ tc35815_open(struct net_device *dev)
  */
 static int tc35815_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct TxFD *txfd;
        unsigned long flags;
 
@@ -1375,7 +1323,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status, int limit)
 static int tc35815_do_interrupt(struct net_device *dev, u32 status)
 #endif
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int ret = -1;
@@ -1392,7 +1340,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Free Descriptor Area Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntBLEx) {
@@ -1401,14 +1349,14 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Buffer List Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntExBD) {
                printk(KERN_WARNING
                       "%s: Excessive Buffer Descriptiors (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
                ret = 0;
        }
 
@@ -1492,7 +1440,7 @@ static void
 tc35815_rx(struct net_device *dev)
 #endif
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned int fdctl;
        int i;
        int buf_free_count = 0;
@@ -1532,7 +1480,7 @@ tc35815_rx(struct net_device *dev)
                        if (skb == NULL) {
                                printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
                                       dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                break;
                        }
                        skb_reserve(skb, 2);   /* 16 bit alignment */
@@ -1602,10 +1550,10 @@ tc35815_rx(struct net_device *dev)
                        netif_rx(skb);
 #endif
                        dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
-                       lp->stats.rx_bytes += pkt_len;
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_len;
                } else {
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        printk(KERN_DEBUG "%s: Rx error (status %x)\n",
                               dev->name, status & Rx_Stat_Mask);
                        /* WORKAROUND: LongErr and CRCErr means Overflow. */
@@ -1613,10 +1561,14 @@ tc35815_rx(struct net_device *dev)
                                status &= ~(Rx_LongErr|Rx_CRCErr);
                                status |= Rx_Over;
                        }
-                       if (status & Rx_LongErr) lp->stats.rx_length_errors++;
-                       if (status & Rx_Over) lp->stats.rx_fifo_errors++;
-                       if (status & Rx_CRCErr) lp->stats.rx_crc_errors++;
-                       if (status & Rx_Align) lp->stats.rx_frame_errors++;
+                       if (status & Rx_LongErr)
+                               dev->stats.rx_length_errors++;
+                       if (status & Rx_Over)
+                               dev->stats.rx_fifo_errors++;
+                       if (status & Rx_CRCErr)
+                               dev->stats.rx_crc_errors++;
+                       if (status & Rx_Align)
+                               dev->stats.rx_frame_errors++;
                }
 
                if (bd_count > 0) {
@@ -1772,14 +1724,14 @@ static int tc35815_poll(struct napi_struct *napi, int budget)
 static void
 tc35815_check_tx_stat(struct net_device *dev, int status)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        const char *msg = NULL;
 
        /* count collisions */
        if (status & Tx_ExColl)
-               lp->stats.collisions += 16;
+               dev->stats.collisions += 16;
        if (status & Tx_TxColl_MASK)
-               lp->stats.collisions += status & Tx_TxColl_MASK;
+               dev->stats.collisions += status & Tx_TxColl_MASK;
 
 #ifndef NO_CHECK_CARRIER
        /* TX4939 does not have NCarr */
@@ -1795,17 +1747,17 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 
        if (!(status & TX_STA_ERR)) {
                /* no error. */
-               lp->stats.tx_packets++;
+               dev->stats.tx_packets++;
                return;
        }
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
        if (status & Tx_ExColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Excessive Collision.";
        }
        if (status & Tx_Under) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Tx FIFO Underrun.";
                if (lp->lstats.tx_underrun < TX_THRESHOLD_KEEP_LIMIT) {
                        lp->lstats.tx_underrun++;
@@ -1818,25 +1770,25 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
                }
        }
        if (status & Tx_Defer) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Excessive Deferral.";
        }
 #ifndef NO_CHECK_CARRIER
        if (status & Tx_NCarr) {
-               lp->stats.tx_carrier_errors++;
+               dev->stats.tx_carrier_errors++;
                msg = "Lost Carrier Sense.";
        }
 #endif
        if (status & Tx_LateColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Late Collision.";
        }
        if (status & Tx_TxPar) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Transmit Parity Error.";
        }
        if (status & Tx_SQErr) {
-               lp->stats.tx_heartbeat_errors++;
+               dev->stats.tx_heartbeat_errors++;
                msg = "Signal Quality Error.";
        }
        if (msg && netif_msg_tx_err(lp))
@@ -1849,7 +1801,7 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 static void
 tc35815_txdone(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct TxFD *txfd;
        unsigned int fdctl;
 
@@ -1878,7 +1830,7 @@ tc35815_txdone(struct net_device *dev)
                BUG_ON(lp->tx_skbs[lp->tfd_end].skb != skb);
 #endif
                if (skb) {
-                       lp->stats.tx_bytes += skb->len;
+                       dev->stats.tx_bytes += skb->len;
                        pci_unmap_single(lp->pci_dev, lp->tx_skbs[lp->tfd_end].skb_dma, skb->len, PCI_DMA_TODEVICE);
                        lp->tx_skbs[lp->tfd_end].skb = NULL;
                        lp->tx_skbs[lp->tfd_end].skb_dma = 0;
@@ -1947,7 +1899,7 @@ tc35815_txdone(struct net_device *dev)
 static int
 tc35815_close(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
 
        netif_stop_queue(dev);
 #ifdef TC35815_NAPI
@@ -1972,34 +1924,30 @@ tc35815_close(struct net_device *dev)
  */
 static struct net_device_stats *tc35815_get_stats(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
-       if (netif_running(dev)) {
+       if (netif_running(dev))
                /* Update the statistics from the device registers. */
-               lp->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
-       }
+               dev->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
 
-       return &lp->stats;
+       return &dev->stats;
 }
 
 static void tc35815_set_cam_entry(struct net_device *dev, int index, unsigned char *addr)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int cam_index = index * 6;
        u32 cam_data;
        u32 saved_addr;
+       DECLARE_MAC_BUF(mac);
+
        saved_addr = tc_readl(&tr->CAM_Adr);
 
-       if (netif_msg_hw(lp)) {
-               int i;
-               printk(KERN_DEBUG "%s: CAM %d:", dev->name, index);
-               for (i = 0; i < 6; i++)
-                       printk(" %02x", addr[i]);
-               printk("\n");
-       }
+       if (netif_msg_hw(lp))
+               printk(KERN_DEBUG "%s: CAM %d: %s\n",
+                       dev->name, index, print_mac(mac, addr));
        if (index & 1) {
                /* read modify write */
                tc_writel(cam_index - 2, &tr->CAM_Adr);
@@ -2044,7 +1992,7 @@ tc35815_set_multicast_list(struct net_device *dev)
 #ifdef WORKAROUND_100HALF_PROMISC
                /* With some (all?) 100MHalf HUB, controller will hang
                 * if we enabled promiscuous mode before linkup... */
-               struct tc35815_local *lp = dev->priv;
+               struct tc35815_local *lp = netdev_priv(dev);
                int pid = lp->phy_addr;
                if (!(tc_mdio_read(dev, pid, MII_BMSR) & BMSR_LSTATUS))
                        return;
@@ -2084,7 +2032,7 @@ tc35815_set_multicast_list(struct net_device *dev)
 
 static void tc35815_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        strcpy(info->driver, MODNAME);
        strcpy(info->version, DRV_VERSION);
        strcpy(info->bus_info, pci_name(lp->pci_dev));
@@ -2092,7 +2040,7 @@ static void tc35815_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *
 
 static int tc35815_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        spin_lock_irq(&lp->lock);
        mii_ethtool_gset(&lp->mii, cmd);
        spin_unlock_irq(&lp->lock);
@@ -2101,7 +2049,7 @@ static int tc35815_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int tc35815_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
 #if 1  /* use our negotiation method... */
        /* Verify the settings we care about. */
@@ -2131,7 +2079,7 @@ static int tc35815_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int tc35815_nway_reset(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
        spin_lock_irq(&lp->lock);
        rc = mii_nway_restart(&lp->mii);
@@ -2141,7 +2089,7 @@ static int tc35815_nway_reset(struct net_device *dev)
 
 static u32 tc35815_get_link(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
        spin_lock_irq(&lp->lock);
        rc = mii_link_ok(&lp->mii);
@@ -2151,19 +2099,19 @@ static u32 tc35815_get_link(struct net_device *dev)
 
 static u32 tc35815_get_msglevel(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        return lp->msg_enable;
 }
 
 static void tc35815_set_msglevel(struct net_device *dev, u32 datum)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        lp->msg_enable = datum;
 }
 
 static int tc35815_get_sset_count(struct net_device *dev, int sset)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
 
        switch (sset) {
        case ETH_SS_STATS:
@@ -2175,7 +2123,7 @@ static int tc35815_get_sset_count(struct net_device *dev, int sset)
 
 static void tc35815_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        data[0] = lp->lstats.max_tx_qlen;
        data[1] = lp->lstats.tx_ints;
        data[2] = lp->lstats.rx_ints;
@@ -2211,7 +2159,7 @@ static const struct ethtool_ops tc35815_ethtool_ops = {
 
 static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
 
        if (!netif_running(dev))
@@ -2283,7 +2231,7 @@ static void tc_mdio_write(struct net_device *dev, int phy_id, int location,
 
 static int tc35815_try_next_permutation(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
 
@@ -2312,7 +2260,7 @@ static int tc35815_try_next_permutation(struct net_device *dev)
 static void
 tc35815_display_link_mode(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short lpa, bmcr;
        char *speed = "", *duplex = "";
@@ -2338,7 +2286,7 @@ tc35815_display_link_mode(struct net_device *dev)
 
 static void tc35815_display_forced_link_mode(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
        char *speed = "", *duplex = "";
@@ -2360,7 +2308,7 @@ static void tc35815_display_forced_link_mode(struct net_device *dev)
 
 static void tc35815_set_link_modes(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int pid = lp->phy_addr;
@@ -2427,7 +2375,7 @@ static void tc35815_set_link_modes(struct net_device *dev)
 static void tc35815_timer(unsigned long data)
 {
        struct net_device *dev = (struct net_device *)data;
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmsr, bmcr, lpa;
        int restart_timer = 0;
@@ -2635,7 +2583,7 @@ out:
 static void tc35815_start_auto_negotiation(struct net_device *dev,
                                           struct ethtool_cmd *ep)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmsr, bmcr, advertize;
        int timeout;
@@ -2759,7 +2707,7 @@ force_link:
 
 static void tc35815_find_phy(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short id0;
 
@@ -2788,7 +2736,7 @@ static void tc35815_find_phy(struct net_device *dev)
 
 static void tc35815_phy_chip_init(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
        struct ethtool_cmd ecmd, *ep;
@@ -2862,7 +2810,7 @@ static void tc35815_chip_reset(struct net_device *dev)
 
 static void tc35815_chip_init(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        unsigned long txctl = TX_CTL_CMD;
@@ -2924,7 +2872,7 @@ static void tc35815_chip_init(struct net_device *dev)
 static int tc35815_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned long flags;
 
        pci_save_state(pdev);
@@ -2942,7 +2890,7 @@ static int tc35815_suspend(struct pci_dev *pdev, pm_message_t state)
 static int tc35815_resume(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned long flags;
 
        pci_restore_state(pdev);