summaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/shpchp_sysfs.c
diff options
context:
space:
mode:
authorrajesh.shah@intel.com <rajesh.shah@intel.com>2005-10-13 12:05:36 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 15:36:59 -0700
commitdbd7a78818d125a0ebd5507d4edb4dd5900006ab (patch)
tree682a1681aad47f70bfb760fca077f54589be92c6 /drivers/pci/hotplug/shpchp_sysfs.c
parente3b1bd572f1cdb247bb4266a593b6894dc578d6a (diff)
downloadblackbird-op-linux-dbd7a78818d125a0ebd5507d4edb4dd5900006ab.tar.gz
blackbird-op-linux-dbd7a78818d125a0ebd5507d4edb4dd5900006ab.zip
[PATCH] shpchp: use the PCI core for hotplug resource management
This patch converts the standard hotplug controller driver to use the PCI core for resource management. This eliminates a whole lot of duplicated code, and integrates shpchp in the system's normal PCI handling code. Signed-off-by: Rajesh Shah <rajesh.shah@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/shpchp_sysfs.c')
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c121
1 files changed, 70 insertions, 51 deletions
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index c9445ebda5c7..b0e781dbcffb 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -40,43 +40,49 @@
static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
{
- struct pci_dev *pci_dev;
- struct controller *ctrl;
+ struct pci_dev *pdev;
char * out = buf;
- int index;
- struct pci_resource *res;
+ int index, busnr;
+ struct resource *res;
+ struct pci_bus *bus;
- pci_dev = container_of (dev, struct pci_dev, dev);
- ctrl = pci_get_drvdata(pci_dev);
+ pdev = container_of (dev, struct pci_dev, dev);
+ bus = pdev->subordinate;
out += sprintf(buf, "Free resources: memory\n");
- index = 11;
- res = ctrl->mem_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
+ if (res && (res->flags & IORESOURCE_MEM) &&
+ !(res->flags & IORESOURCE_PREFETCH)) {
+ out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "Free resources: prefetchable memory\n");
- index = 11;
- res = ctrl->p_mem_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
+ if (res && (res->flags & IORESOURCE_MEM) &&
+ (res->flags & IORESOURCE_PREFETCH)) {
+ out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "Free resources: IO\n");
- index = 11;
- res = ctrl->io_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
+ res = bus->resource[index];
+ if (res && (res->flags & IORESOURCE_IO)) {
+ out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "Free resources: bus numbers\n");
- index = 11;
- res = ctrl->bus_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) {
+ if (!pci_find_bus(pci_domain_nr(bus), busnr))
+ break;
}
+ if (busnr < bus->subordinate)
+ out += sprintf(out, "start = %8.8x, length = %8.8x\n",
+ busnr, (bus->subordinate - busnr));
return out - buf;
}
@@ -84,16 +90,16 @@ static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf)
{
- struct pci_dev *pci_dev;
+ struct pci_dev *pdev, *fdev;
struct controller *ctrl;
char * out = buf;
int index;
- struct pci_resource *res;
+ struct resource *res;
struct pci_func *new_slot;
struct slot *slot;
- pci_dev = container_of (dev, struct pci_dev, dev);
- ctrl = pci_get_drvdata(pci_dev);
+ pdev = container_of (dev, struct pci_dev, dev);
+ ctrl = pci_get_drvdata(pdev);
slot=ctrl->slot;
@@ -101,34 +107,47 @@ static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char
new_slot = shpchp_slot_find(slot->bus, slot->device, 0);
if (!new_slot)
break;
+ fdev = new_slot->pci_dev;
+ if (!fdev)
+ break;
out += sprintf(out, "assigned resources: memory\n");
- index = 11;
- res = new_slot->mem_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index=0; index <= PCI_NUM_RESOURCES; index++) {
+ res = &(fdev->resource[index]);
+ if (res && (res->flags & IORESOURCE_MEM) &&
+ !(res->flags & IORESOURCE_PREFETCH)) {
+ out += sprintf(out,
+ "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "assigned resources: prefetchable memory\n");
- index = 11;
- res = new_slot->p_mem_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index=0; index <= PCI_NUM_RESOURCES; index++) {
+ res = &(fdev->resource[index]);
+ if (res && (res->flags & (IORESOURCE_MEM |
+ IORESOURCE_PREFETCH))) {
+ out += sprintf(out,
+ "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "assigned resources: IO\n");
- index = 11;
- res = new_slot->io_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
+ for (index=0; index <= PCI_NUM_RESOURCES; index++) {
+ res = &(fdev->resource[index]);
+ if (res && (res->flags & IORESOURCE_IO)) {
+ out += sprintf(out,
+ "start = %8.8lx, length = %8.8lx\n",
+ res->start, (res->end - res->start));
+ }
}
out += sprintf(out, "assigned resources: bus numbers\n");
- index = 11;
- res = new_slot->bus_head;
- while (res && index--) {
- out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
- res = res->next;
- }
+ if (fdev->subordinate)
+ out += sprintf(out, "start = %8.8x, length = %8.8x\n",
+ fdev->subordinate->secondary,
+ (fdev->subordinate->subordinate -
+ fdev->subordinate->secondary));
+ else
+ out += sprintf(out, "start = %8.8x, length = %8.8x\n",
+ fdev->bus->number, 1);
slot=slot->next;
}
OpenPOWER on IntegriCloud