diff options
author | Auke Kok <auke-jan.h.kok@intel.com> | 2007-06-08 15:46:36 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 16:02:10 -0700 |
commit | 44c10138fd4bbc4b6d6bff0873c24902f2a9da65 (patch) | |
tree | 6e16d3ec80c87490dc743f72da086356f2906ace /drivers/ide | |
parent | b8a3a5214d7cc115f1ca3a3967b7229d97c46f4a (diff) | |
download | lwn-44c10138fd4bbc4b6d6bff0873c24902f2a9da65.tar.gz lwn-44c10138fd4bbc4b6d6bff0873c24902f2a9da65.zip |
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/ide')
-rw-r--r-- | drivers/ide/pci/alim15x3.c | 2 | ||||
-rw-r--r-- | drivers/ide/pci/amd74xx.c | 8 | ||||
-rw-r--r-- | drivers/ide/pci/cmd64x.c | 9 | ||||
-rw-r--r-- | drivers/ide/pci/hpt366.c | 20 | ||||
-rw-r--r-- | drivers/ide/pci/piix.c | 6 | ||||
-rw-r--r-- | drivers/ide/pci/serverworks.c | 13 | ||||
-rw-r--r-- | drivers/ide/pci/sis5513.c | 8 | ||||
-rw-r--r-- | drivers/ide/pci/sl82c105.c | 4 | ||||
-rw-r--r-- | drivers/ide/pci/via82cxxx.c | 9 |
9 files changed, 22 insertions, 57 deletions
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 8a6b27b3bcc3..ba0fb92b0417 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -508,7 +508,7 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c u8 tmpbyte; struct pci_dev *north = pci_get_slot(dev->bus, PCI_DEVFN(0,0)); - pci_read_config_byte(dev, PCI_REVISION_ID, &m5229_revision); + m5229_revision = dev->revision; isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 84ed30cdb324..8d30b99a54d8 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c @@ -123,8 +123,7 @@ static int amd74xx_get_info(char *buffer, char **addr, off_t offset, int count) amd_print("Driver Version: 2.13"); amd_print("South Bridge: %s", pci_name(bmide_dev)); - pci_read_config_byte(dev, PCI_REVISION_ID, &t); - amd_print("Revision: IDE %#x", t); + amd_print("Revision: IDE %#x", dev->revision); amd_print("Highest DMA rate: UDMA%s", amd_dma[fls(amd_config->udma_mask) - 1]); amd_print("BM-DMA base: %#lx", amd_base); @@ -312,8 +311,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch */ if (amd_config->flags & AMD_CHECK_SWDMA) { - pci_read_config_byte(dev, PCI_REVISION_ID, &t); - if (t <= 7) + if (dev->revision <= 7) amd_config->flags |= AMD_BAD_SWDMA; } @@ -383,7 +381,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch pci_read_config_byte(dev, PCI_REVISION_ID, &t); printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", - amd_chipset->name, pci_name(dev), t, + amd_chipset->name, pci_name(dev), dev->revision, amd_dma[fls(amd_config->udma_mask) - 1]); /* diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 8631b6c8aa15..1e89dd6e5bbf 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -88,7 +88,6 @@ static char * print_cmd64x_get_info (char *buf, struct pci_dev *dev, int index) u8 reg72 = 0, reg73 = 0; /* primary */ u8 reg7a = 0, reg7b = 0; /* secondary */ u8 reg50 = 1, reg51 = 1, reg57 = 0, reg71 = 0; /* extra */ - u8 rev = 0; p += sprintf(p, "\nController: %d\n", index); p += sprintf(p, "PCI-%x Chipset.\n", dev->device); @@ -103,9 +102,8 @@ static char * print_cmd64x_get_info (char *buf, struct pci_dev *dev, int index) (void) pci_read_config_byte(dev, UDIDETCR1, ®7b); /* PCI0643/6 originally didn't have the primary channel enable bit */ - (void) pci_read_config_byte(dev, PCI_REVISION_ID, &rev); if ((dev->device == PCI_DEVICE_ID_CMD_643) || - (dev->device == PCI_DEVICE_ID_CMD_646 && rev < 3)) + (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 3)) reg51 |= CNTRL_ENA_1ST; p += sprintf(p, "---------------- Primary Channel " @@ -604,14 +602,11 @@ static int __devinit init_setup_cmd64x(struct pci_dev *dev, ide_pci_device_t *d) static int __devinit init_setup_cmd646(struct pci_dev *dev, ide_pci_device_t *d) { - u8 rev = 0; - /* * The original PCI0646 didn't have the primary channel enable bit, * it appeared starting with PCI0646U (i.e. revision ID 3). */ - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - if (rev < 3) + if (dev->revision < 3) d->enablebits[0].reg = 0; return ide_setup_pci_device(dev, d); diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 4b6bae8eee82..e9b07a97c340 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1413,11 +1413,9 @@ static int __devinit init_setup_hpt372n(struct pci_dev *dev, ide_pci_device_t *d static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) { struct hpt_info *info; - u8 rev = 0, mcr1 = 0; + u8 mcr1 = 0; - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - - if (rev > 1) { + if (dev->revision > 1) { d->name = "HPT371N"; info = &hpt371n; @@ -1442,11 +1440,8 @@ static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) static int __devinit init_setup_hpt372a(struct pci_dev *dev, ide_pci_device_t *d) { struct hpt_info *info; - u8 rev = 0; - - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - if (rev > 1) { + if (dev->revision > 1) { d->name = "HPT372N"; info = &hpt372n; @@ -1460,11 +1455,8 @@ static int __devinit init_setup_hpt372a(struct pci_dev *dev, ide_pci_device_t *d static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d) { struct hpt_info *info; - u8 rev = 0; - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - - if (rev > 1) { + if (dev->revision > 1) { d->name = "HPT302N"; info = &hpt302n; @@ -1478,7 +1470,7 @@ static int __devinit init_setup_hpt302(struct pci_dev *dev, ide_pci_device_t *d) static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) { struct pci_dev *dev2; - u8 rev = 0; + u8 rev = dev->revision; static char *chipset_names[] = { "HPT366", "HPT366", "HPT368", "HPT370", "HPT370A", "HPT372", "HPT372N" }; @@ -1489,8 +1481,6 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) if (PCI_FUNC(dev->devfn) & 1) return -ENODEV; - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - switch (rev) { case 0: case 1: diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 2e0b29ef596a..1372c35be035 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -572,18 +572,16 @@ static void __devinit piix_check_450nx(void) { struct pci_dev *pdev = NULL; u16 cfg; - u8 rev; while((pdev=pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev))!=NULL) { /* Look for 450NX PXB. Check for problem configurations A PCI quirk checks bit 6 already */ - pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); pci_read_config_word(pdev, 0x41, &cfg); /* Only on the original revision: IDE DMA can hang */ - if(rev == 0x00) + if (pdev->revision == 0x00) no_piix_dma = 1; /* On all revisions below 5 PXB bus lock must be disabled for IDE */ - else if(cfg & (1<<14) && rev < 5) + else if (cfg & (1<<14) && pdev->revision < 5) no_piix_dma = 2; } if(no_piix_dma) diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index 1371b5bf6bf0..ed04e0c8dd4c 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -55,7 +55,6 @@ static const char *svwks_bad_ata100[] = { NULL }; -static u8 svwks_revision = 0; static struct pci_dev *isa_dev; static int check_in_drive_lists (ide_drive_t *drive, const char **list) @@ -71,9 +70,6 @@ static u8 svwks_udma_filter(ide_drive_t *drive) struct pci_dev *dev = HWIF(drive)->pci_dev; u8 mask = 0; - if (!svwks_revision) - pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision); - if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) return 0x1f; if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { @@ -88,9 +84,9 @@ static u8 svwks_udma_filter(ide_drive_t *drive) return 0; /* Check the OSB4 DMA33 enable bit */ return ((reg & 0x00004000) == 0x00004000) ? 0x07 : 0; - } else if (svwks_revision < SVWKS_CSB5_REVISION_NEW) { + } else if (dev->revision < SVWKS_CSB5_REVISION_NEW) { return 0x07; - } else if (svwks_revision >= SVWKS_CSB5_REVISION_NEW) { + } else if (dev->revision >= SVWKS_CSB5_REVISION_NEW) { u8 btr = 0, mode; pci_read_config_byte(dev, 0x5A, &btr); mode = btr & 0x3; @@ -234,9 +230,6 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha unsigned int reg; u8 btr; - /* save revision id to determine DMA capability */ - pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision); - /* force Master Latency Timer value to 64 PCICLKs */ pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40); @@ -315,7 +308,7 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha if (!(PCI_FUNC(dev->devfn) & 1)) btr |= 0x2; else - btr |= (svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2; + btr |= (dev->revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2; pci_write_config_byte(dev, 0x5A, btr); } /* Setup HT1000 SouthBridge Controller - Single Channel Only */ diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index f875183ac8d9..756a9b6eb462 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -659,9 +659,7 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c /* Special case for SiS630 : 630S/ET is ATA_100a */ if (SiSHostChipInfo[i].host_id == PCI_DEVICE_ID_SI_630) { - u8 hostrev; - pci_read_config_byte(host, PCI_REVISION_ID, &hostrev); - if (hostrev >= 0x30) + if (host->revision >= 0x30) chipset_family = ATA_100a; } pci_dev_put(host); @@ -702,7 +700,6 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c u16 trueid; u8 prefctl; u8 idecfg; - u8 sbrev; pci_read_config_byte(dev, 0x4a, &idecfg); pci_write_config_byte(dev, 0x4a, idecfg | 0x10); @@ -712,11 +709,10 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c if (trueid == 0x5517) { /* SiS 961/961B */ lpc_bridge = pci_get_slot(dev->bus, 0x10); /* Bus 0, Dev 2, Fn 0 */ - pci_read_config_byte(lpc_bridge, PCI_REVISION_ID, &sbrev); pci_read_config_byte(dev, 0x49, &prefctl); pci_dev_put(lpc_bridge); - if (sbrev == 0x10 && (prefctl & 0x80)) { + if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { printk(KERN_INFO "SIS5513: SiS 961B MuTIOL IDE UDMA133 controller\n"); chipset_family = ATA_133a; } else { diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 487879842af4..a7323d278c49 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c @@ -338,7 +338,6 @@ static void sl82c105_tune_drive(ide_drive_t *drive, u8 pio) static unsigned int sl82c105_bridge_revision(struct pci_dev *dev) { struct pci_dev *bridge; - u8 rev; /* * The bridge should be part of the same device, but function 0. @@ -360,10 +359,9 @@ static unsigned int sl82c105_bridge_revision(struct pci_dev *dev) /* * We need to find function 0's revision, not function 1 */ - pci_read_config_byte(bridge, PCI_REVISION_ID, &rev); pci_dev_put(bridge); - return rev; + return bridge->revision; } /* diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index d21dd2e7eeb3..27e92fb9f95e 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c @@ -237,16 +237,14 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive) static struct via_isa_bridge *via_config_find(struct pci_dev **isa) { struct via_isa_bridge *via_config; - u8 t; for (via_config = via_isa_bridges; via_config->id; via_config++) if ((*isa = pci_get_device(PCI_VENDOR_ID_VIA + !!(via_config->flags & VIA_BAD_ID), via_config->id, NULL))) { - pci_read_config_byte(*isa, PCI_REVISION_ID, &t); - if (t >= via_config->rev_min && - t <= via_config->rev_max) + if ((*isa)->revision >= via_config->rev_min && + (*isa)->revision <= via_config->rev_max) break; pci_dev_put(*isa); } @@ -404,10 +402,9 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const * Print the boot message. */ - pci_read_config_byte(isa, PCI_REVISION_ID, &t); printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) IDE %sDMA%s " "controller on pci%s\n", - via_config->name, t, + via_config->name, isa->revision, via_config->udma_mask ? "U" : "MW", via_dma[via_config->udma_mask ? (fls(via_config->udma_mask) - 1) : 0], |