On Fri, Jun 08, 2007 at 03:46:30PM -0700, Auke Kok wrote:Currently there are 97 occurrences where drivers need the pci
revision ID. We can do this once for all devices. Even the pci
subsystem needs the revision several times for quirks. The extra
u8 member pads out nicely in the pci_dev struct.
Good idea. I always wondered why we read the invariants so often
in the code.
Signed-off-by: Auke Kok <auke-jan.h.kok@xxxxxxxxx>
drivers/pci/probe.c | 3 +++
include/linux/pci.h | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e48fcf0..0fdb71d 100644
@@ -918,6 +918,9 @@ pci_scan_device(struct pci_bus *bus, int devfn)
dev->cfg_size = pci_cfg_space_size(dev);
dev->error_state = pci_channel_io_normal;
+ /* read the PCI revision: 1 byte */
+ pci_read_config_byte(dev, PCI_REVISION_ID, &dev->revision);
probe.c:pci_setup_device() is also reading this byte but discards it:
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
class >>= 8; /* upper 3 bytes */
dev->class = class;
Can you use "class & 0xff"? Or is pci_setup_device() too late?
Or can you read the whole 32-bits in pci_scan_device() and remove
the pci_read_config() in pci_setup_device()?