From 44c10138fd4bbc4b6d6bff0873c24902f2a9da65 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 8 Jun 2007 15:46:36 -0700 Subject: 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 Acked-by: Dave Jones Signed-off-by: Greg Kroah-Hartman --- drivers/atm/eni.c | 9 +-------- drivers/atm/idt77252.c | 13 +++---------- drivers/atm/iphase.c | 11 ++++------- drivers/atm/lanai.c | 13 ++----------- drivers/atm/zatm.c | 6 ++---- 5 files changed, 12 insertions(+), 40 deletions(-) (limited to 'drivers/atm') diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index 0d3a38b1cb0..77637e780d4 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) struct pci_dev *pci_dev; unsigned long real_base; void __iomem *base; - unsigned char revision; int error,i,last; DPRINTK(">eni_init\n"); @@ -1715,12 +1714,6 @@ static int __devinit eni_do_init(struct atm_dev *dev) pci_dev = eni_dev->pci_dev; real_base = pci_resource_start(pci_dev, 0); eni_dev->irq = pci_dev->irq; - error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision); - if (error) { - printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n", - dev->number,error); - return -EINVAL; - } if ((error = pci_write_config_word(pci_dev,PCI_COMMAND, PCI_COMMAND_MEMORY | (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { @@ -1729,7 +1722,7 @@ static int __devinit eni_do_init(struct atm_dev *dev) return -EIO; } printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%lx,irq=%d,", - dev->number,revision,real_base,eni_dev->irq); + dev->number,pci_dev->revision,real_base,eni_dev->irq); if (!(base = ioremap_nocache(real_base,MAP_MAX_SIZE))) { printk("\n"); 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 3800bc0cb2e..8f995ce8d73 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) unsigned long membase, srambase; struct idt77252_dev *card; struct atm_dev *dev; - ushort revision = 0; int i, err; @@ -3688,19 +3687,13 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id) return err; } - if (pci_read_config_word(pcidev, PCI_REVISION_ID, &revision)) { - printk("idt77252-%d: can't read PCI_REVISION_ID\n", index); - err = -ENODEV; - goto err_out_disable_pdev; - } - card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); if (!card) { printk("idt77252-%d: can't allocate private data\n", index); err = -ENOMEM; goto err_out_disable_pdev; } - card->revision = revision; + card->revision = pcidev->revision; card->index = index; card->pcidev = pcidev; sprintf(card->name, "idt77252-%d", card->index); @@ -3762,8 +3755,8 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id) } printk("%s: ABR SAR (Rev %c): MEM %08lx SRAM %08lx [%u KB]\n", - card->name, ((revision > 1) && (revision < 25)) ? - 'A' + revision - 1 : '?', membase, srambase, + card->name, ((card->revision > 1) && (card->revision < 25)) ? + 'A' + card->revision - 1 : '?', membase, srambase, card->sramsize / 1024); if (init_card(dev)) { diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index bb7ef570514..a3b605a0ca1 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c @@ -2290,7 +2290,6 @@ static int __devinit ia_init(struct atm_dev *dev) unsigned long real_base; void __iomem *base; unsigned short command; - unsigned char revision; int error, i; /* The device has been identified and registered. Now we read @@ -2305,16 +2304,14 @@ static int __devinit ia_init(struct atm_dev *dev) real_base = pci_resource_start (iadev->pci, 0); iadev->irq = iadev->pci->irq; - if ((error = pci_read_config_word(iadev->pci, PCI_COMMAND,&command)) - || (error = pci_read_config_byte(iadev->pci, - PCI_REVISION_ID,&revision))) - { + error = pci_read_config_word(iadev->pci, PCI_COMMAND, &command); + if (error) { printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%x\n", dev->number,error); return -EINVAL; } IF_INIT(printk(DEV_LABEL "(itf %d): rev.%d,realbase=0x%lx,irq=%d\n", - dev->number, revision, real_base, iadev->irq);) + dev->number, iadev->pci->revision, real_base, iadev->irq);) /* find mapping size of board */ @@ -2353,7 +2350,7 @@ static int __devinit ia_init(struct atm_dev *dev) return error; } IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n", - dev->number, revision, base, iadev->irq);) + dev->number, iadev->pci->revision, base, iadev->irq);) /* filling the iphase dev structure */ iadev->mem = iadev->pci_map_size /2; diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index 09f477d4237..203c70378b1 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c @@ -293,7 +293,6 @@ struct lanai_dev { struct atm_vcc *cbrvcc; int number; int board_rev; - u8 pci_revision; /* TODO - look at race conditions with maintence of conf1/conf2 */ /* TODO - transmit locking: should we use _irq not _irqsave? */ /* TODO - organize above in some rational fashion (see ) */ @@ -1969,14 +1968,6 @@ static int __devinit lanai_pci_start(struct lanai_dev *lanai) "(itf %d): No suitable DMA available.\n", lanai->number); return -EBUSY; } - /* Get the pci revision byte */ - result = pci_read_config_byte(pci, PCI_REVISION_ID, - &lanai->pci_revision); - if (result != PCIBIOS_SUCCESSFUL) { - printk(KERN_ERR DEV_LABEL "(itf %d): can't read " - "PCI_REVISION_ID: %d\n", lanai->number, result); - return -EINVAL; - } result = pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &w); if (result != PCIBIOS_SUCCESSFUL) { printk(KERN_ERR DEV_LABEL "(itf %d): can't read " @@ -2254,7 +2245,7 @@ static int __devinit lanai_dev_open(struct atm_dev *atmdev) lanai_timed_poll_start(lanai); printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d, base=0x%lx, irq=%u " "(%02X-%02X-%02X-%02X-%02X-%02X)\n", lanai->number, - (int) lanai->pci_revision, (unsigned long) lanai->base, + (int) lanai->pci->revision, (unsigned long) lanai->base, lanai->pci->irq, atmdev->esi[0], atmdev->esi[1], atmdev->esi[2], 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) (unsigned int) lanai->magicno, lanai->num_vci); if (left-- == 0) return sprintf(page, "revision: board=%d, pci_if=%d\n", - lanai->board_rev, (int) lanai->pci_revision); + lanai->board_rev, (int) lanai->pci->revision); if (left-- == 0) return sprintf(page, "EEPROM ESI: " "%02X:%02X:%02X:%02X:%02X:%02X\n", diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 2ad2527cf5b..020a87a476c 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -1182,7 +1182,6 @@ static int __devinit zatm_init(struct atm_dev *dev) struct zatm_dev *zatm_dev; struct pci_dev *pci_dev; unsigned short command; - unsigned char revision; int error,i,last; unsigned long t0,t1,t2; @@ -1192,8 +1191,7 @@ static int __devinit zatm_init(struct atm_dev *dev) pci_dev = zatm_dev->pci_dev; zatm_dev->base = pci_resource_start(pci_dev, 0); zatm_dev->irq = pci_dev->irq; - if ((error = pci_read_config_word(pci_dev,PCI_COMMAND,&command)) || - (error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision))) { + if ((error = pci_read_config_word(pci_dev,PCI_COMMAND,&command))) { printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n", dev->number,error); return -EINVAL; @@ -1206,7 +1204,7 @@ static int __devinit zatm_init(struct atm_dev *dev) } eprom_get_esi(dev); printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%x,irq=%d,", - dev->number,revision,zatm_dev->base,zatm_dev->irq); + dev->number,pci_dev->revision,zatm_dev->base,zatm_dev->irq); /* reset uPD98401 */ zout(0,SWR); while (!(zin(GSR) & uPD98401_INT_IND)); -- cgit v1.2.3-18-g5258