aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip/dmfe.c
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/dmfe.c
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/dmfe.c')
-rw-r--r--drivers/net/tulip/dmfe.c26
1 files changed, 12 insertions, 14 deletions
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;