aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2008-11-03 19:49:57 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-03 19:49:57 -0500
commit63532394af307795ea637a283bd1fd057f5dfcea (patch)
treed078a0e3339cf7d6df60c42ab6c28ed2495b9eca
parentc88e668b52c8cd8bc55b6734c7dfbb0cb005d445 (diff)
tg3: Use pci_ioremap_bar()
This patch replaces the existing APE register mapping code with a call to pci_ioremap_bar(). The code that maps the main device register space did not undergo a similar change because the information derived from the pci_resource_start() and pci_resource_len() is still used to populate the (optional) mem_start and mem_end netdevice members. Replace hardcoded constants where appropriate. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tg3.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index b47e8a1a41f..e129a6a581f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -54,6 +54,9 @@
54#include <asm/prom.h> 54#include <asm/prom.h>
55#endif 55#endif
56 56
57#define BAR_0 0
58#define BAR_2 2
59
57#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 60#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
58#define TG3_VLAN_TAG_USED 1 61#define TG3_VLAN_TAG_USED 1
59#else 62#else
@@ -13247,8 +13250,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13247 const struct pci_device_id *ent) 13250 const struct pci_device_id *ent)
13248{ 13251{
13249 static int tg3_version_printed = 0; 13252 static int tg3_version_printed = 0;
13250 resource_size_t tg3reg_base; 13253 resource_size_t tg3reg_len;
13251 unsigned long tg3reg_len;
13252 struct net_device *dev; 13254 struct net_device *dev;
13253 struct tg3 *tp; 13255 struct tg3 *tp;
13254 int err, pm_cap; 13256 int err, pm_cap;
@@ -13265,7 +13267,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13265 return err; 13267 return err;
13266 } 13268 }
13267 13269
13268 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 13270 if (!(pci_resource_flags(pdev, BAR_0) & IORESOURCE_MEM)) {
13269 printk(KERN_ERR PFX "Cannot find proper PCI device " 13271 printk(KERN_ERR PFX "Cannot find proper PCI device "
13270 "base address, aborting.\n"); 13272 "base address, aborting.\n");
13271 err = -ENODEV; 13273 err = -ENODEV;
@@ -13290,9 +13292,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13290 goto err_out_free_res; 13292 goto err_out_free_res;
13291 } 13293 }
13292 13294
13293 tg3reg_base = pci_resource_start(pdev, 0);
13294 tg3reg_len = pci_resource_len(pdev, 0);
13295
13296 dev = alloc_etherdev(sizeof(*tp)); 13295 dev = alloc_etherdev(sizeof(*tp));
13297 if (!dev) { 13296 if (!dev) {
13298 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n"); 13297 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
@@ -13344,7 +13343,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13344 spin_lock_init(&tp->indirect_lock); 13343 spin_lock_init(&tp->indirect_lock);
13345 INIT_WORK(&tp->reset_task, tg3_reset_task); 13344 INIT_WORK(&tp->reset_task, tg3_reset_task);
13346 13345
13347 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len); 13346 dev->mem_start = pci_resource_start(pdev, BAR_0);
13347 tg3reg_len = pci_resource_len(pdev, BAR_0);
13348 dev->mem_end = dev->mem_start + tg3reg_len;
13349
13350 tp->regs = ioremap_nocache(dev->mem_start, tg3reg_len);
13348 if (!tp->regs) { 13351 if (!tp->regs) {
13349 printk(KERN_ERR PFX "Cannot map device registers, " 13352 printk(KERN_ERR PFX "Cannot map device registers, "
13350 "aborting.\n"); 13353 "aborting.\n");
@@ -13467,17 +13470,14 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13467 } 13470 }
13468 13471
13469 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 13472 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
13470 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { 13473 if (!(pci_resource_flags(pdev, BAR_2) & IORESOURCE_MEM)) {
13471 printk(KERN_ERR PFX "Cannot find proper PCI device " 13474 printk(KERN_ERR PFX "Cannot find proper PCI device "
13472 "base address for APE, aborting.\n"); 13475 "base address for APE, aborting.\n");
13473 err = -ENODEV; 13476 err = -ENODEV;
13474 goto err_out_iounmap; 13477 goto err_out_iounmap;
13475 } 13478 }
13476 13479
13477 tg3reg_base = pci_resource_start(pdev, 2); 13480 tp->aperegs = pci_ioremap_bar(pdev, BAR_2);
13478 tg3reg_len = pci_resource_len(pdev, 2);
13479
13480 tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len);
13481 if (!tp->aperegs) { 13481 if (!tp->aperegs) {
13482 printk(KERN_ERR PFX "Cannot map APE registers, " 13482 printk(KERN_ERR PFX "Cannot map APE registers, "
13483 "aborting.\n"); 13483 "aborting.\n");