bnx2: stop using net_device.{base_addr, irq}.
authorFrancois Romieu <romieu@fr.zoreil.com>
Fri, 9 Mar 2012 13:51:47 +0000 (14:51 +0100)
committerFrancois Romieu <romieu@fr.zoreil.com>
Sat, 7 Apr 2012 09:45:26 +0000 (11:45 +0200)
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Acked-by: Michael Chan <mchan@broadcom.com>
drivers/net/ethernet/broadcom/bnx2.c

index 8297e2868736382a5301a31d56711a7c3a9ae4b3..36037a6778205bfb9673803ec72e85672c13fba0 100644 (file)
@@ -7976,7 +7976,6 @@ static int __devinit
 bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 {
        struct bnx2 *bp;
-       unsigned long mem_len;
        int rc, i, j;
        u32 reg;
        u64 dma_mask, persist_dma_mask;
@@ -8036,13 +8035,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 #endif
        INIT_WORK(&bp->reset_task, bnx2_reset_task);
 
-       dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
-       mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1);
-       dev->mem_end = dev->mem_start + mem_len;
-       dev->irq = pdev->irq;
-
-       bp->regview = ioremap_nocache(dev->base_addr, mem_len);
-
+       bp->regview = pci_iomap(pdev, 0, MB_GET_CID_ADDR(TX_TSS_CID +
+                                                        TX_MAX_TSS_RINGS + 1));
        if (!bp->regview) {
                dev_err(&pdev->dev, "Cannot map register space, aborting\n");
                rc = -ENOMEM;
@@ -8346,10 +8340,8 @@ err_out_unmap:
                bp->flags &= ~BNX2_FLAG_AER_ENABLED;
        }
 
-       if (bp->regview) {
-               iounmap(bp->regview);
-               bp->regview = NULL;
-       }
+       pci_iounmap(pdev, bp->regview);
+       bp->regview = NULL;
 
 err_out_release:
        pci_release_regions(pdev);
@@ -8432,7 +8424,7 @@ static int __devinit
 bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int version_printed = 0;
-       struct net_device *dev = NULL;
+       struct net_device *dev;
        struct bnx2 *bp;
        int rc;
        char str[40];
@@ -8442,15 +8434,12 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        /* dev zeroed in init_etherdev */
        dev = alloc_etherdev_mq(sizeof(*bp), TX_MAX_RINGS);
-
        if (!dev)
                return -ENOMEM;
 
        rc = bnx2_init_board(pdev, dev);
-       if (rc < 0) {
-               free_netdev(dev);
-               return rc;
-       }
+       if (rc < 0)
+               goto err_free;
 
        dev->netdev_ops = &bnx2_netdev_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
@@ -8480,22 +8469,21 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto error;
        }
 
-       netdev_info(dev, "%s (%c%d) %s found at mem %lx, IRQ %d, node addr %pM\n",
-                   board_info[ent->driver_data].name,
+       netdev_info(dev, "%s (%c%d) %s found at mem %lx, IRQ %d, "
+                   "node addr %pM\n", board_info[ent->driver_data].name,
                    ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
                    ((CHIP_ID(bp) & 0x0ff0) >> 4),
-                   bnx2_bus_string(bp, str),
-                   dev->base_addr,
-                   bp->pdev->irq, dev->dev_addr);
+                   bnx2_bus_string(bp, str), (long)pci_resource_start(pdev, 0),
+                   pdev->irq, dev->dev_addr);
 
        return 0;
 
 error:
-       if (bp->regview)
-               iounmap(bp->regview);
+       iounmap(bp->regview);
        pci_release_regions(pdev);
        pci_disable_device(pdev);
        pci_set_drvdata(pdev, NULL);
+err_free:
        free_netdev(dev);
        return rc;
 }
@@ -8511,8 +8499,7 @@ bnx2_remove_one(struct pci_dev *pdev)
        del_timer_sync(&bp->timer);
        cancel_work_sync(&bp->reset_task);
 
-       if (bp->regview)
-               iounmap(bp->regview);
+       pci_iounmap(bp->pdev, bp->regview);
 
        kfree(bp->temp_stats_blk);