Re: [PATCH] PCI fixes for 2.6.10-rc1

Greg KH
2004-11-12T23:25:59Z

ChangeSet 1.2026.66.13, 2004/11/05 15:05:24-08:00, matthew@wil.cx

[PATCH] PCI: add pci_fixup_early

Port Ivan's early PCI fixups patch to 2.6.10-rc1. Also fix some indentation
to make it less than 80 columns.

From: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>

drivers/pci/probe.c | 3 +++
include/asm-generic/vmlinux.lds.h | 3 +++
include/linux/pci.h | 34 ++++++++++++++++++----------------
3 files changed, 24 insertions(+), 16 deletions(-)

diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c 2004-11-12 15:13:20 -08:00
+++ b/drivers/pci/probe.c 2004-11-12 15:13:20 -08:00
@@ -478,6 +478,9 @@
/* "Unknown power state" */
dev->current_state = 4;

+ /* Early fixups, before probing the BARs */
+ pci_fixup_device(pci_fixup_early, dev);
+
switch (dev->hdr_type) { /* header type */
case PCI_HEADER_TYPE_NORMAL: /* standard header */
if (class == PCI_CLASS_BRIDGE_PCI)
diff -Nru a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
--- a/include/asm-generic/vmlinux.lds.h 2004-11-12 15:13:20 -08:00
+++ b/include/asm-generic/vmlinux.lds.h 2004-11-12 15:13:20 -08:00
@@ -18,6 +18,9 @@
\
/* PCI quirks */ \
.pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
+ VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
+ *(.pci_fixup_early) \
+ VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
*(.pci_fixup_header) \
VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h 2004-11-12 15:13:20 -08:00
+++ b/include/linux/pci.h 2004-11-12 15:13:20 -08:00
@@ -989,31 +989,33 @@
*/

struct pci_fixup {
- u16 vendor, device; /* You can use PCI_ANY_ID here of course */
+ u16 vendor, device; /* You can use PCI_ANY_ID here of course */
void (*hook)(struct pci_dev *dev);
};

enum pci_fixup_pass {
- pci_fixup_header, /* Called immediately after reading configuration header */
+ pci_fixup_early, /* Before probing BARs */
+ pci_fixup_header, /* After reading configuration header */
pci_fixup_final, /* Final phase of device fixups */
pci_fixup_enable, /* pci_enable_device() time */
};

/* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
- static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \
- __attribute__((__section__(".pci_fixup_header"))) = { \
- vendor, device, hook };
-
-#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
- static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \
- __attribute__((__section__(".pci_fixup_final"))) = { \
- vendor, device, hook };
-
-#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
- static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \
- __attribute__((__section__(".pci_fixup_enable"))) = { \
- vendor, device, hook };
+#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
+ static struct pci_fixup __pci_fixup_##name __attribute_used__ \
+ __attribute__((__section__(#section))) = { vendor, device, hook };
+#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
+ vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
+ vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
+ vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
+ vendor##device##hook, vendor, device, hook)

void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);