提交 275f165f 编写于 作者: A Arjan van de Ven 提交者: Jeff Garzik

pci: use pci_ioremap_bar() in drivers/net

Use the newly introduced pci_ioremap_bar() function in drivers/net.
pci_ioremap_bar() just takes a pci device and a bar number, with the goal
of making it really hard to get wrong, while also having a central place
to stick sanity checks.
Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: NJeff Garzik <jgarzik@redhat.com>
上级 842e08bd
...@@ -10087,8 +10087,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, ...@@ -10087,8 +10087,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
dev->irq = pdev->irq; dev->irq = pdev->irq;
bp->regview = ioremap_nocache(dev->base_addr, bp->regview = pci_ioremap_bar(pdev, 0);
pci_resource_len(pdev, 0));
if (!bp->regview) { if (!bp->regview) {
printk(KERN_ERR PFX "Cannot map register space, aborting\n"); printk(KERN_ERR PFX "Cannot map register space, aborting\n");
rc = -ENOMEM; rc = -ENOMEM;
......
...@@ -966,8 +966,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -966,8 +966,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
hw->back = adapter; hw->back = adapter;
err = -EIO; err = -EIO;
hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0), hw->hw_addr = pci_ioremap_bar(pdev, BAR_0);
pci_resource_len(pdev, BAR_0));
if (!hw->hw_addr) if (!hw->hw_addr)
goto err_ioremap; goto err_ioremap;
...@@ -1015,9 +1014,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -1015,9 +1014,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
* because it depends on mac_type */ * because it depends on mac_type */
if ((hw->mac_type == e1000_ich8lan) && if ((hw->mac_type == e1000_ich8lan) &&
(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
hw->flash_address = hw->flash_address = pci_ioremap_bar(pdev, 1);
ioremap(pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1));
if (!hw->flash_address) if (!hw->flash_address)
goto err_flashmap; goto err_flashmap;
} }
......
...@@ -363,7 +363,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev, ...@@ -363,7 +363,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
ioaddr = pci_resource_start (pdev, 0); ioaddr = pci_resource_start (pdev, 0);
#else #else
ioaddr = pci_resource_start (pdev, 1); ioaddr = pci_resource_start (pdev, 1);
ioaddr = (long) ioremap (ioaddr, pci_resource_len (pdev, 1)); ioaddr = (long) pci_ioremap_bar(pdev, 1);
if (!ioaddr) { if (!ioaddr) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
goto err_out_free_netdev; goto err_out_free_netdev;
......
...@@ -381,8 +381,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -381,8 +381,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
adapter->hw.back = adapter; adapter->hw.back = adapter;
adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT); adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT);
adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0), adapter->hw.hw_addr = pci_ioremap_bar(pdev, BAR_0);
pci_resource_len(pdev, BAR_0));
if (!adapter->hw.hw_addr) { if (!adapter->hw.hw_addr) {
err = -EIO; err = -EIO;
goto err_ioremap; goto err_ioremap;
......
...@@ -3977,9 +3977,7 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev, ...@@ -3977,9 +3977,7 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
if (qdev->device_id == QL3032_DEVICE_ID) if (qdev->device_id == QL3032_DEVICE_ID)
ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
qdev->mem_map_registers = qdev->mem_map_registers = pci_ioremap_bar(pdev, 1);
ioremap_nocache(pci_resource_start(pdev, 1),
pci_resource_len(qdev->pdev, 1));
if (!qdev->mem_map_registers) { if (!qdev->mem_map_registers) {
printk(KERN_ERR PFX "%s: cannot map device registers\n", printk(KERN_ERR PFX "%s: cannot map device registers\n",
pci_name(pdev)); pci_name(pdev));
......
...@@ -7917,8 +7917,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -7917,8 +7917,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
goto mem_alloc_failed; goto mem_alloc_failed;
} }
sp->bar0 = ioremap(pci_resource_start(pdev, 0), sp->bar0 = pci_ioremap_bar(pdev, 0);
pci_resource_len(pdev, 0));
if (!sp->bar0) { if (!sp->bar0) {
DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem1\n", DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem1\n",
dev->name); dev->name);
...@@ -7926,8 +7925,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -7926,8 +7925,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
goto bar0_remap_failed; goto bar0_remap_failed;
} }
sp->bar1 = ioremap(pci_resource_start(pdev, 2), sp->bar1 = pci_ioremap_bar(pdev, 2);
pci_resource_len(pdev, 2));
if (!sp->bar1) { if (!sp->bar1) {
DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem2\n", DBG_PRINT(ERR_DBG, "%s: Neterion: cannot remap io mem2\n",
dev->name); dev->name);
......
...@@ -730,8 +730,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev, ...@@ -730,8 +730,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
goto err_free_mmio_region_1; goto err_free_mmio_region_1;
} }
ioaddr = ioremap(pci_resource_start(pdev, 0), ioaddr = pci_ioremap_bar(pdev, 0);
pci_resource_len(pdev, 0));
if (!ioaddr) { if (!ioaddr) {
printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n", printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n",
DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0), DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0),
......
...@@ -379,7 +379,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, ...@@ -379,7 +379,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
card->scabase = ioremap(scaphys, PC300_SCA_SIZE); card->scabase = ioremap(scaphys, PC300_SCA_SIZE);
ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK; ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
card->rambase = ioremap(ramphys, pci_resource_len(pdev,3)); card->rambase = pci_ioremap_bar(pdev, 3);
if (card->plxbase == NULL || if (card->plxbase == NULL ||
card->scabase == NULL || card->scabase == NULL ||
......
...@@ -343,7 +343,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, ...@@ -343,7 +343,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE); card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE);
ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK; ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
card->rambase = ioremap(ramphys, pci_resource_len(pdev,3)); card->rambase = pci_ioremap_bar(pdev, 3);
if (card->plxbase == NULL || if (card->plxbase == NULL ||
card->scabase == NULL || card->scabase == NULL ||
......
...@@ -312,7 +312,7 @@ static int prism2_pci_probe(struct pci_dev *pdev, ...@@ -312,7 +312,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
goto err_out_disable; goto err_out_disable;
} }
mem = ioremap(phymem, pci_resource_len(pdev, 0)); mem = pci_ioremap_bar(pdev, 0);
if (mem == NULL) { if (mem == NULL) {
printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ; printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ;
goto fail; goto fail;
......
...@@ -11621,7 +11621,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev, ...@@ -11621,7 +11621,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
length = pci_resource_len(pdev, 0); length = pci_resource_len(pdev, 0);
priv->hw_len = length; priv->hw_len = length;
base = ioremap_nocache(pci_resource_start(pdev, 0), length); base = pci_ioremap_bar(pdev, 0);
if (!base) { if (!base) {
err = -ENODEV; err = -ENODEV;
goto out_pci_release_regions; goto out_pci_release_regions;
......
...@@ -222,8 +222,7 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) ...@@ -222,8 +222,7 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), rt2x00dev->csr.base = pci_ioremap_bar(pci_dev, 0);
pci_resource_len(pci_dev, 0));
if (!rt2x00dev->csr.base) if (!rt2x00dev->csr.base)
goto exit; goto exit;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册