Centralize capability related functions into several new functions and put PCI resource definitions into an enum.
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Alex Chiang <achiang@hp.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
---
drivers/pci/pci-sysfs.c | 119 +++++++++++++++++++++++++++--------------------
drivers/pci/pci.c | 68 ++++++++++++++++++++-------
drivers/pci/pci.h | 3 +
drivers/pci/probe.c | 29 ++++++++---
drivers/pci/proc.c | 7 ++-
drivers/pci/setup-bus.c | 4 +-
drivers/pci/setup-res.c | 27 +++++------
include/linux/pci.h | 39 ++++++++++------
8 files changed, 186 insertions(+), 110 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index f99160d..f2feebc 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -100,11 +100,11 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
struct pci_dev * pci_dev = to_pci_dev(dev);
char * str = buf;
int i;
- int max = 7;
+ int max;
resource_size_t start, end;
- if (pci_dev->subordinate)
- max = DEVICE_COUNT_RESOURCE;
+ max = pci_dev->subordinate ? DEVICE_COUNT_RESOURCE :
+ PCI_BRIDGE_RESOURCES;
for (i = 0; i < max; i++) {
struct resource *res = &pci_dev->resource[i];
@@ -716,10 +716,40 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev)
return 0;
}
+static int pci_create_capabilities_sysfs(struct pci_dev *dev)
+{
+ int retval;
+ struct bin_attribute *attr;
+
+ /* If the device has VPD, try to expose it in sysfs. */
+ if (dev->vpd) {
+ attr = kzalloc(sizeof(*attr), GFP_ATOMIC);
+ ...