Commit ad798386 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Greg Kroah-Hartman

[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: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 95eb2fb8
...@@ -478,6 +478,9 @@ static int pci_setup_device(struct pci_dev * dev) ...@@ -478,6 +478,9 @@ static int pci_setup_device(struct pci_dev * dev)
/* "Unknown power state" */ /* "Unknown power state" */
dev->current_state = 4; dev->current_state = 4;
/* Early fixups, before probing the BARs */
pci_fixup_device(pci_fixup_early, dev);
switch (dev->hdr_type) { /* header type */ switch (dev->hdr_type) { /* header type */
case PCI_HEADER_TYPE_NORMAL: /* standard header */ case PCI_HEADER_TYPE_NORMAL: /* standard header */
if (class == PCI_CLASS_BRIDGE_PCI) if (class == PCI_CLASS_BRIDGE_PCI)
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
\ \
/* PCI quirks */ \ /* PCI quirks */ \
.pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \ .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) = .; \ VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
*(.pci_fixup_header) \ *(.pci_fixup_header) \
VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \ VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
......
...@@ -989,31 +989,33 @@ static inline char *pci_name(struct pci_dev *pdev) ...@@ -989,31 +989,33 @@ static inline char *pci_name(struct pci_dev *pdev)
*/ */
struct pci_fixup { 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); void (*hook)(struct pci_dev *dev);
}; };
enum pci_fixup_pass { 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_final, /* Final phase of device fixups */
pci_fixup_enable, /* pci_enable_device() time */ pci_fixup_enable, /* pci_enable_device() time */
}; };
/* Anonymous variables would be nice... */ /* Anonymous variables would be nice... */
#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \ #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \ static struct pci_fixup __pci_fixup_##name __attribute_used__ \
__attribute__((__section__(".pci_fixup_header"))) = { \ __attribute__((__section__(#section))) = { vendor, device, hook };
vendor, device, hook }; #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \ vendor##device##hook, vendor, device, hook)
static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \ #define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
__attribute__((__section__(".pci_fixup_final"))) = { \ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
vendor, device, hook }; vendor##device##hook, vendor, device, hook)
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__ \ vendor##device##hook, vendor, device, hook)
__attribute__((__section__(".pci_fixup_enable"))) = { \ #define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
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); void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment