aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm
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/atm
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/atm')
-rw-r--r--drivers/atm/eni.c9
-rw-r--r--drivers/atm/idt77252.c13
-rw-r--r--drivers/atm/iphase.c11
-rw-r--r--drivers/atm/lanai.c13
-rw-r--r--drivers/atm/zatm.c6
5 files changed, 12 insertions, 40 deletions
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 0d3a38b1cb0b..77637e780d41 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1704,7 +1704,6 @@ static int __devinit eni_do_init(struct atm_dev *dev)
1704 struct pci_dev *pci_dev; 1704 struct pci_dev *pci_dev;
1705 unsigned long real_base; 1705 unsigned long real_base;
1706 void __iomem *base; 1706 void __iomem *base;
1707 unsigned char revision;
1708 int error,i,last; 1707 int error,i,last;
1709 1708
1710 DPRINTK(">eni_init\n"); 1709 DPRINTK(">eni_init\n");
@@ -1715,12 +1714,6 @@ static int __devinit eni_do_init(struct atm_dev *dev)
1715 pci_dev = eni_dev->pci_dev; 1714 pci_dev = eni_dev->pci_dev;
1716 real_base = pci_resource_start(pci_dev, 0); 1715 real_base = pci_resource_start(pci_dev, 0);
1717 eni_dev->irq = pci_dev->irq; 1716 eni_dev->irq = pci_dev->irq;
1718 error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision);
1719 if (error) {
1720 printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n",
1721 dev->number,error);
1722 return -EINVAL;
1723 }
1724 if ((error = pci_write_config_word(pci_dev,PCI_COMMAND, 1717 if ((error = pci_write_config_word(pci_dev,PCI_COMMAND,
1725 PCI_COMMAND_MEMORY | 1718 PCI_COMMAND_MEMORY |
1726 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { 1719 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) {
@@ -1729,7 +1722,7 @@ static int __devinit eni_do_init(struct atm_dev *dev)
1729 return -EIO; 1722 return -EIO;
1730 } 1723 }
1731 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%lx,irq=%d,", 1724 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%lx,irq=%d,",
1732 dev->number,revision,real_base,eni_dev->irq); 1725 dev->number,pci_dev->revision,real_base,eni_dev->irq);
1733 if (!(base = ioremap_nocache(real_base,MAP_MAX_SIZE))) { 1726 if (!(base = ioremap_nocache(real_base,MAP_MAX_SIZE))) {
1734 printk("\n"); 1727 printk("\n");
1735 printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page " 1728 printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page "
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 3800bc0cb2ef..8f995ce8d73b 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3679,7 +3679,6 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3679 unsigned long membase, srambase; 3679 unsigned long membase, srambase;
3680 struct idt77252_dev *card; 3680 struct idt77252_dev *card;
3681 struct atm_dev *dev; 3681 struct atm_dev *dev;
3682 ushort revision = 0;
3683 int i, err; 3682 int i, err;
3684 3683
3685 3684
@@ -3688,19 +3687,13 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3688 return err; 3687 return err;
3689 } 3688 }
3690 3689
3691 if (pci_read_config_word(pcidev, PCI_REVISION_ID, &revision)) {
3692 printk("idt77252-%d: can't read PCI_REVISION_ID\n", index);
3693 err = -ENODEV;
3694 goto err_out_disable_pdev;
3695 }
3696
3697 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); 3690 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
3698 if (!card) { 3691 if (!card) {
3699 printk("idt77252-%d: can't allocate private data\n", index); 3692 printk("idt77252-%d: can't allocate private data\n", index);
3700 err = -ENOMEM; 3693 err = -ENOMEM;
3701 goto err_out_disable_pdev; 3694 goto err_out_disable_pdev;
3702 } 3695 }
3703 card->revision = revision; 3696 card->revision = pcidev->revision;
3704 card->index = index; 3697 card->index = index;
3705 card->pcidev = pcidev; 3698 card->pcidev = pcidev;
3706 sprintf(card->name, "idt77252-%d", card->index); 3699 sprintf(card->name, "idt77252-%d", card->index);
@@ -3762,8 +3755,8 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3762 } 3755 }
3763 3756
3764 printk("%s: ABR SAR (Rev %c): MEM %08lx SRAM %08lx [%u KB]\n", 3757 printk("%s: ABR SAR (Rev %c): MEM %08lx SRAM %08lx [%u KB]\n",
3765 card->name, ((revision > 1) && (revision < 25)) ? 3758 card->name, ((card->revision > 1) && (card->revision < 25)) ?
3766 'A' + revision - 1 : '?', membase, srambase, 3759 'A' + card->revision - 1 : '?', membase, srambase,
3767 card->sramsize / 1024); 3760 card->sramsize / 1024);
3768 3761
3769 if (init_card(dev)) { 3762 if (init_card(dev)) {
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index bb7ef570514c..a3b605a0ca17 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -2290,7 +2290,6 @@ static int __devinit ia_init(struct atm_dev *dev)
2290 unsigned long real_base; 2290 unsigned long real_base;
2291 void __iomem *base; 2291 void __iomem *base;
2292 unsigned short command; 2292 unsigned short command;
2293 unsigned char revision;
2294 int error, i; 2293 int error, i;
2295 2294
2296 /* The device has been identified and registered. Now we read 2295 /* The device has been identified and registered. Now we read
@@ -2305,16 +2304,14 @@ static int __devinit ia_init(struct atm_dev *dev)
2305 real_base = pci_resource_start (iadev->pci, 0); 2304 real_base = pci_resource_start (iadev->pci, 0);
2306 iadev->irq = iadev->pci->irq; 2305 iadev->irq = iadev->pci->irq;
2307 2306
2308 if ((error = pci_read_config_word(iadev->pci, PCI_COMMAND,&command)) 2307 error = pci_read_config_word(iadev->pci, PCI_COMMAND, &command);
2309 || (error = pci_read_config_byte(iadev->pci, 2308 if (error) {
2310 PCI_REVISION_ID,&revision)))
2311 {
2312 printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%x\n", 2309 printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%x\n",
2313 dev->number,error); 2310 dev->number,error);
2314 return -EINVAL; 2311 return -EINVAL;
2315 } 2312 }
2316 IF_INIT(printk(DEV_LABEL "(itf %d): rev.%d,realbase=0x%lx,irq=%d\n", 2313 IF_INIT(printk(DEV_LABEL "(itf %d): rev.%d,realbase=0x%lx,irq=%d\n",
2317 dev->number, revision, real_base, iadev->irq);) 2314 dev->number, iadev->pci->revision, real_base, iadev->irq);)
2318 2315
2319 /* find mapping size of board */ 2316 /* find mapping size of board */
2320 2317
@@ -2353,7 +2350,7 @@ static int __devinit ia_init(struct atm_dev *dev)
2353 return error; 2350 return error;
2354 } 2351 }
2355 IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n", 2352 IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n",
2356 dev->number, revision, base, iadev->irq);) 2353 dev->number, iadev->pci->revision, base, iadev->irq);)
2357 2354
2358 /* filling the iphase dev structure */ 2355 /* filling the iphase dev structure */
2359 iadev->mem = iadev->pci_map_size /2; 2356 iadev->mem = iadev->pci_map_size /2;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 09f477d4237a..203c70378b15 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -293,7 +293,6 @@ struct lanai_dev {
293 struct atm_vcc *cbrvcc; 293 struct atm_vcc *cbrvcc;
294 int number; 294 int number;
295 int board_rev; 295 int board_rev;
296 u8 pci_revision;
297/* TODO - look at race conditions with maintence of conf1/conf2 */ 296/* TODO - look at race conditions with maintence of conf1/conf2 */
298/* TODO - transmit locking: should we use _irq not _irqsave? */ 297/* TODO - transmit locking: should we use _irq not _irqsave? */
299/* TODO - organize above in some rational fashion (see <asm/cache.h>) */ 298/* TODO - organize above in some rational fashion (see <asm/cache.h>) */
@@ -1969,14 +1968,6 @@ static int __devinit lanai_pci_start(struct lanai_dev *lanai)
1969 "(itf %d): No suitable DMA available.\n", lanai->number); 1968 "(itf %d): No suitable DMA available.\n", lanai->number);
1970 return -EBUSY; 1969 return -EBUSY;
1971 } 1970 }
1972 /* Get the pci revision byte */
1973 result = pci_read_config_byte(pci, PCI_REVISION_ID,
1974 &lanai->pci_revision);
1975 if (result != PCIBIOS_SUCCESSFUL) {
1976 printk(KERN_ERR DEV_LABEL "(itf %d): can't read "
1977 "PCI_REVISION_ID: %d\n", lanai->number, result);
1978 return -EINVAL;
1979 }
1980 result = pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &w); 1971 result = pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &w);
1981 if (result != PCIBIOS_SUCCESSFUL) { 1972 if (result != PCIBIOS_SUCCESSFUL) {
1982 printk(KERN_ERR DEV_LABEL "(itf %d): can't read " 1973 printk(KERN_ERR DEV_LABEL "(itf %d): can't read "
@@ -2254,7 +2245,7 @@ static int __devinit lanai_dev_open(struct atm_dev *atmdev)
2254 lanai_timed_poll_start(lanai); 2245 lanai_timed_poll_start(lanai);
2255 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d, base=0x%lx, irq=%u " 2246 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d, base=0x%lx, irq=%u "
2256 "(%02X-%02X-%02X-%02X-%02X-%02X)\n", lanai->number, 2247 "(%02X-%02X-%02X-%02X-%02X-%02X)\n", lanai->number,
2257 (int) lanai->pci_revision, (unsigned long) lanai->base, 2248 (int) lanai->pci->revision, (unsigned long) lanai->base,
2258 lanai->pci->irq, 2249 lanai->pci->irq,
2259 atmdev->esi[0], atmdev->esi[1], atmdev->esi[2], 2250 atmdev->esi[0], atmdev->esi[1], atmdev->esi[2],
2260 atmdev->esi[3], atmdev->esi[4], atmdev->esi[5]); 2251 atmdev->esi[3], atmdev->esi[4], atmdev->esi[5]);
@@ -2491,7 +2482,7 @@ static int lanai_proc_read(struct atm_dev *atmdev, loff_t *pos, char *page)
2491 (unsigned int) lanai->magicno, lanai->num_vci); 2482 (unsigned int) lanai->magicno, lanai->num_vci);
2492 if (left-- == 0) 2483 if (left-- == 0)
2493 return sprintf(page, "revision: board=%d, pci_if=%d\n", 2484 return sprintf(page, "revision: board=%d, pci_if=%d\n",
2494 lanai->board_rev, (int) lanai->pci_revision); 2485 lanai->board_rev, (int) lanai->pci->revision);
2495 if (left-- == 0) 2486 if (left-- == 0)
2496 return sprintf(page, "EEPROM ESI: " 2487 return sprintf(page, "EEPROM ESI: "
2497 "%02X:%02X:%02X:%02X:%02X:%02X\n", 2488 "%02X:%02X:%02X:%02X:%02X:%02X\n",
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2ad2527cf5b3..020a87a476c8 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -1182,7 +1182,6 @@ static int __devinit zatm_init(struct atm_dev *dev)
1182 struct zatm_dev *zatm_dev; 1182 struct zatm_dev *zatm_dev;
1183 struct pci_dev *pci_dev; 1183 struct pci_dev *pci_dev;
1184 unsigned short command; 1184 unsigned short command;
1185 unsigned char revision;
1186 int error,i,last; 1185 int error,i,last;
1187 unsigned long t0,t1,t2; 1186 unsigned long t0,t1,t2;
1188 1187
@@ -1192,8 +1191,7 @@ static int __devinit zatm_init(struct atm_dev *dev)
1192 pci_dev = zatm_dev->pci_dev; 1191 pci_dev = zatm_dev->pci_dev;
1193 zatm_dev->base = pci_resource_start(pci_dev, 0); 1192 zatm_dev->base = pci_resource_start(pci_dev, 0);
1194 zatm_dev->irq = pci_dev->irq; 1193 zatm_dev->irq = pci_dev->irq;
1195 if ((error = pci_read_config_word(pci_dev,PCI_COMMAND,&command)) || 1194 if ((error = pci_read_config_word(pci_dev,PCI_COMMAND,&command))) {
1196 (error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision))) {
1197 printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n", 1195 printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n",
1198 dev->number,error); 1196 dev->number,error);
1199 return -EINVAL; 1197 return -EINVAL;
@@ -1206,7 +1204,7 @@ static int __devinit zatm_init(struct atm_dev *dev)
1206 } 1204 }
1207 eprom_get_esi(dev); 1205 eprom_get_esi(dev);
1208 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%x,irq=%d,", 1206 printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%x,irq=%d,",
1209 dev->number,revision,zatm_dev->base,zatm_dev->irq); 1207 dev->number,pci_dev->revision,zatm_dev->base,zatm_dev->irq);
1210 /* reset uPD98401 */ 1208 /* reset uPD98401 */
1211 zout(0,SWR); 1209 zout(0,SWR);
1212 while (!(zin(GSR) & uPD98401_INT_IND)); 1210 while (!(zin(GSR) & uPD98401_INT_IND));