aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip
diff options
context:
space:
mode:
authorAuke Kok <auke-jan.h.kok@intel.com>2007-06-08 18:46:36 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:02:10 -0400
commit44c10138fd4bbc4b6d6bff0873c24902f2a9da65 (patch)
tree6e16d3ec80c87490dc743f72da086356f2906ace /drivers/net/tulip
parentb8a3a5214d7cc115f1ca3a3967b7229d97c46f4a (diff)
PCI: Change all drivers to use pci_device->revision
Instead of all drivers reading pci config space to get the revision ID, they can now use the pci_device->revision member. This exposes some issues where drivers where reading a word or a dword for the revision number, and adding useless error-handling around the read. Some drivers even just read it for no purpose of all. In devices where the revision ID is being copied over and used in what appears to be the equivalent of hotpath, I have left the copy code and the cached copy as not to influence the driver's performance. Compile tested with make all{yes,mod}config on x86_64 and i386. Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Acked-by: Dave Jones <davej@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/net/tulip')
-rw-r--r--drivers/net/tulip/de4x5.c8
-rw-r--r--drivers/net/tulip/dmfe.c26
-rw-r--r--drivers/net/tulip/tulip_core.c13
-rw-r--r--drivers/net/tulip/xircom_cb.c5
-rw-r--r--drivers/net/tulip/xircom_tulip_cb.c4
5 files changed, 22 insertions, 34 deletions
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 42fca26afc50..09902891a6e6 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -2134,7 +2134,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2134 u_short vendor, status; 2134 u_short vendor, status;
2135 u_int irq = 0, device; 2135 u_int irq = 0, device;
2136 u_long iobase = 0; /* Clear upper 32 bits in Alphas */ 2136 u_long iobase = 0; /* Clear upper 32 bits in Alphas */
2137 int i, j, cfrv; 2137 int i, j;
2138 struct de4x5_private *lp = netdev_priv(dev); 2138 struct de4x5_private *lp = netdev_priv(dev);
2139 struct list_head *walk; 2139 struct list_head *walk;
2140 2140
@@ -2150,7 +2150,6 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2150 2150
2151 /* Get the chip configuration revision register */ 2151 /* Get the chip configuration revision register */
2152 pb = this_dev->bus->number; 2152 pb = this_dev->bus->number;
2153 pci_read_config_dword(this_dev, PCI_REVISION_ID, &cfrv);
2154 2153
2155 /* Set the device number information */ 2154 /* Set the device number information */
2156 lp->device = PCI_SLOT(this_dev->devfn); 2155 lp->device = PCI_SLOT(this_dev->devfn);
@@ -2158,7 +2157,8 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2158 2157
2159 /* Set the chipset information */ 2158 /* Set the chipset information */
2160 if (is_DC2114x) { 2159 if (is_DC2114x) {
2161 device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); 2160 device = ((this_dev->revision & CFRV_RN) < DC2114x_BRK
2161 ? DC21142 : DC21143);
2162 } 2162 }
2163 lp->chipset = device; 2163 lp->chipset = device;
2164 2164
@@ -2254,7 +2254,7 @@ static int __devinit de4x5_pci_probe (struct pci_dev *pdev,
2254 } 2254 }
2255 2255
2256 /* Get the chip configuration revision register */ 2256 /* Get the chip configuration revision register */
2257 pci_read_config_dword(pdev, PCI_REVISION_ID, &lp->cfrv); 2257 lp->cfrv = pdev->revision;
2258 2258
2259 /* Set the device number information */ 2259 /* Set the device number information */
2260 lp->device = dev_num; 2260 lp->device = dev_num;
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 4ed67ff0e81e..dab74feb44bc 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -181,11 +181,12 @@
181 udelay(5); 181 udelay(5);
182 182
183#define __CHK_IO_SIZE(pci_id, dev_rev) \ 183#define __CHK_IO_SIZE(pci_id, dev_rev) \
184 (( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) >= 0x02000030) ) ? \ 184 (( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) >= 0x30) ) ? \
185 DM9102A_IO_SIZE: DM9102_IO_SIZE) 185 DM9102A_IO_SIZE: DM9102_IO_SIZE)
186 186
187#define CHK_IO_SIZE(pci_dev, dev_rev) \ 187#define CHK_IO_SIZE(pci_dev) \
188 (__CHK_IO_SIZE(((pci_dev)->device << 16) | (pci_dev)->vendor, dev_rev)) 188 (__CHK_IO_SIZE(((pci_dev)->device << 16) | (pci_dev)->vendor, \
189 (pci_dev)->revision))
189 190
190/* Sten Check */ 191/* Sten Check */
191#define DEVICE net_device 192#define DEVICE net_device
@@ -205,7 +206,7 @@ struct rx_desc {
205 206
206struct dmfe_board_info { 207struct dmfe_board_info {
207 u32 chip_id; /* Chip vendor/Device ID */ 208 u32 chip_id; /* Chip vendor/Device ID */
208 u32 chip_revision; /* Chip revision */ 209 u8 chip_revision; /* Chip revision */
209 struct DEVICE *next_dev; /* next device */ 210 struct DEVICE *next_dev; /* next device */
210 struct pci_dev *pdev; /* PCI device */ 211 struct pci_dev *pdev; /* PCI device */
211 spinlock_t lock; 212 spinlock_t lock;
@@ -359,7 +360,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
359{ 360{
360 struct dmfe_board_info *db; /* board information structure */ 361 struct dmfe_board_info *db; /* board information structure */
361 struct net_device *dev; 362 struct net_device *dev;
362 u32 dev_rev, pci_pmr; 363 u32 pci_pmr;
363 int i, err; 364 int i, err;
364 365
365 DMFE_DBUG(0, "dmfe_init_one()", 0); 366 DMFE_DBUG(0, "dmfe_init_one()", 0);
@@ -392,10 +393,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
392 goto err_out_disable; 393 goto err_out_disable;
393 } 394 }
394 395
395 /* Read Chip revision */ 396 if (pci_resource_len(pdev, 0) < (CHK_IO_SIZE(pdev)) ) {
396 pci_read_config_dword(pdev, PCI_REVISION_ID, &dev_rev);
397
398 if (pci_resource_len(pdev, 0) < (CHK_IO_SIZE(pdev, dev_rev)) ) {
399 printk(KERN_ERR DRV_NAME ": Allocated I/O size too small\n"); 397 printk(KERN_ERR DRV_NAME ": Allocated I/O size too small\n");
400 err = -ENODEV; 398 err = -ENODEV;
401 goto err_out_disable; 399 goto err_out_disable;
@@ -433,7 +431,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
433 431
434 db->chip_id = ent->driver_data; 432 db->chip_id = ent->driver_data;
435 db->ioaddr = pci_resource_start(pdev, 0); 433 db->ioaddr = pci_resource_start(pdev, 0);
436 db->chip_revision = dev_rev; 434 db->chip_revision = pdev->revision;
437 db->wol_mode = 0; 435 db->wol_mode = 0;
438 436
439 db->pdev = pdev; 437 db->pdev = pdev;
@@ -455,7 +453,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
455 453
456 pci_read_config_dword(pdev, 0x50, &pci_pmr); 454 pci_read_config_dword(pdev, 0x50, &pci_pmr);
457 pci_pmr &= 0x70000; 455 pci_pmr &= 0x70000;
458 if ( (pci_pmr == 0x10000) && (dev_rev == 0x02000031) ) 456 if ( (pci_pmr == 0x10000) && (db->chip_revision == 0x31) )
459 db->chip_type = 1; /* DM9102A E3 */ 457 db->chip_type = 1; /* DM9102A E3 */
460 else 458 else
461 db->chip_type = 0; 459 db->chip_type = 0;
@@ -553,7 +551,7 @@ static int dmfe_open(struct DEVICE *dev)
553 551
554 /* CR6 operation mode decision */ 552 /* CR6 operation mode decision */
555 if ( !chkmode || (db->chip_id == PCI_DM9132_ID) || 553 if ( !chkmode || (db->chip_id == PCI_DM9132_ID) ||
556 (db->chip_revision >= 0x02000030) ) { 554 (db->chip_revision >= 0x30) ) {
557 db->cr6_data |= DMFE_TXTH_256; 555 db->cr6_data |= DMFE_TXTH_256;
558 db->cr0_data = CR0_DEFAULT; 556 db->cr0_data = CR0_DEFAULT;
559 db->dm910x_chk_mode=4; /* Enter the normal mode */ 557 db->dm910x_chk_mode=4; /* Enter the normal mode */
@@ -1199,9 +1197,9 @@ static void dmfe_timer(unsigned long data)
1199 tmp_cr12 = inb(db->ioaddr + DCR12); /* DM9102/DM9102A */ 1197 tmp_cr12 = inb(db->ioaddr + DCR12); /* DM9102/DM9102A */
1200 1198
1201 if ( ((db->chip_id == PCI_DM9102_ID) && 1199 if ( ((db->chip_id == PCI_DM9102_ID) &&
1202 (db->chip_revision == 0x02000030)) || 1200 (db->chip_revision == 0x30)) ||
1203 ((db->chip_id == PCI_DM9132_ID) && 1201 ((db->chip_id == PCI_DM9132_ID) &&
1204 (db->chip_revision == 0x02000010)) ) { 1202 (db->chip_revision == 0x10)) ) {
1205 /* DM9102A Chip */ 1203 /* DM9102A Chip */
1206 if (tmp_cr12 & 2) 1204 if (tmp_cr12 & 2)
1207 link_ok = 0; 1205 link_ok = 0;
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 041af63f2811..1a9e911b86a2 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1238,7 +1238,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1238 }; 1238 };
1239 static int last_irq; 1239 static int last_irq;
1240 static int multiport_cnt; /* For four-port boards w/one EEPROM */ 1240 static int multiport_cnt; /* For four-port boards w/one EEPROM */
1241 u8 chip_rev;
1242 int i, irq; 1241 int i, irq;
1243 unsigned short sum; 1242 unsigned short sum;
1244 unsigned char *ee_data; 1243 unsigned char *ee_data;
@@ -1274,10 +1273,8 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1274 1273
1275 if (pdev->vendor == 0x1282 && pdev->device == 0x9100) 1274 if (pdev->vendor == 0x1282 && pdev->device == 0x9100)
1276 { 1275 {
1277 u32 dev_rev;
1278 /* Read Chip revision */ 1276 /* Read Chip revision */
1279 pci_read_config_dword(pdev, PCI_REVISION_ID, &dev_rev); 1277 if (pdev->revision < 0x02000030)
1280 if(dev_rev < 0x02000030)
1281 { 1278 {
1282 printk(KERN_ERR PFX "skipping early DM9100 with Crc bug (use dmfe)\n"); 1279 printk(KERN_ERR PFX "skipping early DM9100 with Crc bug (use dmfe)\n");
1283 return -ENODEV; 1280 return -ENODEV;
@@ -1360,8 +1357,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1360 if (!ioaddr) 1357 if (!ioaddr)
1361 goto err_out_free_res; 1358 goto err_out_free_res;
1362 1359
1363 pci_read_config_byte (pdev, PCI_REVISION_ID, &chip_rev);
1364
1365 /* 1360 /*
1366 * initialize private data structure 'tp' 1361 * initialize private data structure 'tp'
1367 * it is zeroed and aligned in alloc_etherdev 1362 * it is zeroed and aligned in alloc_etherdev
@@ -1382,7 +1377,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1382 tp->flags = tulip_tbl[chip_idx].flags; 1377 tp->flags = tulip_tbl[chip_idx].flags;
1383 tp->pdev = pdev; 1378 tp->pdev = pdev;
1384 tp->base_addr = ioaddr; 1379 tp->base_addr = ioaddr;
1385 tp->revision = chip_rev; 1380 tp->revision = pdev->revision;
1386 tp->csr0 = csr0; 1381 tp->csr0 = csr0;
1387 spin_lock_init(&tp->lock); 1382 spin_lock_init(&tp->lock);
1388 spin_lock_init(&tp->mii_lock); 1383 spin_lock_init(&tp->mii_lock);
@@ -1399,7 +1394,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1399 tulip_mwi_config (pdev, dev); 1394 tulip_mwi_config (pdev, dev);
1400#else 1395#else
1401 /* MWI is broken for DC21143 rev 65... */ 1396 /* MWI is broken for DC21143 rev 65... */
1402 if (chip_idx == DC21143 && chip_rev == 65) 1397 if (chip_idx == DC21143 && pdev->revision == 65)
1403 tp->csr0 &= ~MWI; 1398 tp->csr0 &= ~MWI;
1404#endif 1399#endif
1405 1400
@@ -1640,7 +1635,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1640#else 1635#else
1641 "Port" 1636 "Port"
1642#endif 1637#endif
1643 " %#llx,", dev->name, chip_name, chip_rev, 1638 " %#llx,", dev->name, chip_name, pdev->revision,
1644 (unsigned long long) pci_resource_start(pdev, TULIP_BAR)); 1639 (unsigned long long) pci_resource_start(pdev, TULIP_BAR));
1645 pci_set_drvdata(pdev, dev); 1640 pci_set_drvdata(pdev, dev);
1646 1641
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 2470b1ee33c0..79943cdd6337 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -205,7 +205,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
205{ 205{
206 struct net_device *dev = NULL; 206 struct net_device *dev = NULL;
207 struct xircom_private *private; 207 struct xircom_private *private;
208 unsigned char chip_rev;
209 unsigned long flags; 208 unsigned long flags;
210 unsigned short tmp16; 209 unsigned short tmp16;
211 enter("xircom_probe"); 210 enter("xircom_probe");
@@ -224,8 +223,6 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
224 pci_read_config_word (pdev,PCI_STATUS, &tmp16); 223 pci_read_config_word (pdev,PCI_STATUS, &tmp16);
225 pci_write_config_word (pdev, PCI_STATUS,tmp16); 224 pci_write_config_word (pdev, PCI_STATUS,tmp16);
226 225
227 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev);
228
229 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) { 226 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) {
230 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n"); 227 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n");
231 return -ENODEV; 228 return -ENODEV;
@@ -286,7 +283,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
286 goto reg_fail; 283 goto reg_fail;
287 } 284 }
288 285
289 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq); 286 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, pdev->revision, pdev->irq);
290 /* start the transmitter to get a heartbeat */ 287 /* start the transmitter to get a heartbeat */
291 /* TODO: send 2 dummy packets here */ 288 /* TODO: send 2 dummy packets here */
292 transceiver_voodoo(private); 289 transceiver_voodoo(private);
diff --git a/drivers/net/tulip/xircom_tulip_cb.c b/drivers/net/tulip/xircom_tulip_cb.c
index f64172927377..83d69f11892f 100644
--- a/drivers/net/tulip/xircom_tulip_cb.c
+++ b/drivers/net/tulip/xircom_tulip_cb.c
@@ -524,7 +524,6 @@ static int __devinit xircom_init_one(struct pci_dev *pdev, const struct pci_devi
524 int chip_idx = id->driver_data; 524 int chip_idx = id->driver_data;
525 long ioaddr; 525 long ioaddr;
526 int i; 526 int i;
527 u8 chip_rev;
528 527
529/* when built into the kernel, we only print version if device is found */ 528/* when built into the kernel, we only print version if device is found */
530#ifndef MODULE 529#ifndef MODULE
@@ -620,9 +619,8 @@ static int __devinit xircom_init_one(struct pci_dev *pdev, const struct pci_devi
620 if (register_netdev(dev)) 619 if (register_netdev(dev))
621 goto err_out_cleardev; 620 goto err_out_cleardev;
622 621
623 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev);
624 printk(KERN_INFO "%s: %s rev %d at %#3lx,", 622 printk(KERN_INFO "%s: %s rev %d at %#3lx,",
625 dev->name, xircom_tbl[chip_idx].chip_name, chip_rev, ioaddr); 623 dev->name, xircom_tbl[chip_idx].chip_name, pdev->revision, ioaddr);
626 for (i = 0; i < 6; i++) 624 for (i = 0; i < 6; i++)
627 printk("%c%2.2X", i ? ':' : ' ', dev->dev_addr[i]); 625 printk("%c%2.2X", i ? ':' : ' ', dev->dev_addr[i]);
628 printk(", IRQ %d.\n", dev->irq); 626 printk(", IRQ %d.\n", dev->irq);