diff options
author | rajesh.shah@intel.com <rajesh.shah@intel.com> | 2005-10-13 15:05:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 18:36:59 -0400 |
commit | dbd7a78818d125a0ebd5507d4edb4dd5900006ab (patch) | |
tree | 682a1681aad47f70bfb760fca077f54589be92c6 /drivers/pci/hotplug/shpchp_sysfs.c | |
parent | e3b1bd572f1cdb247bb4266a593b6894dc578d6a (diff) |
[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.c | 121 |
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 @@ | |||
40 | 40 | ||
41 | static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) | 41 | static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) |
42 | { | 42 | { |
43 | struct pci_dev *pci_dev; | 43 | struct pci_dev *pdev; |
44 | struct controller *ctrl; | ||
45 | char * out = buf; | 44 | char * out = buf; |
46 | int index; | 45 | int index, busnr; |
47 | struct pci_resource *res; | 46 | struct resource *res; |
47 | struct pci_bus *bus; | ||
48 | 48 | ||
49 | pci_dev = container_of (dev, struct pci_dev, dev); | 49 | pdev = container_of (dev, struct pci_dev, dev); |
50 | ctrl = pci_get_drvdata(pci_dev); | 50 | bus = pdev->subordinate; |
51 | 51 | ||
52 | out += sprintf(buf, "Free resources: memory\n"); | 52 | out += sprintf(buf, "Free resources: memory\n"); |
53 | index = 11; | 53 | for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { |
54 | res = ctrl->mem_head; | 54 | res = bus->resource[index]; |
55 | while (res && index--) { | 55 | if (res && (res->flags & IORESOURCE_MEM) && |
56 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 56 | !(res->flags & IORESOURCE_PREFETCH)) { |
57 | res = res->next; | 57 | out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", |
58 | res->start, (res->end - res->start)); | ||
59 | } | ||
58 | } | 60 | } |
59 | out += sprintf(out, "Free resources: prefetchable memory\n"); | 61 | out += sprintf(out, "Free resources: prefetchable memory\n"); |
60 | index = 11; | 62 | for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { |
61 | res = ctrl->p_mem_head; | 63 | res = bus->resource[index]; |
62 | while (res && index--) { | 64 | if (res && (res->flags & IORESOURCE_MEM) && |
63 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 65 | (res->flags & IORESOURCE_PREFETCH)) { |
64 | res = res->next; | 66 | out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", |
67 | res->start, (res->end - res->start)); | ||
68 | } | ||
65 | } | 69 | } |
66 | out += sprintf(out, "Free resources: IO\n"); | 70 | out += sprintf(out, "Free resources: IO\n"); |
67 | index = 11; | 71 | for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) { |
68 | res = ctrl->io_head; | 72 | res = bus->resource[index]; |
69 | while (res && index--) { | 73 | if (res && (res->flags & IORESOURCE_IO)) { |
70 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 74 | out += sprintf(out, "start = %8.8lx, length = %8.8lx\n", |
71 | res = res->next; | 75 | res->start, (res->end - res->start)); |
76 | } | ||
72 | } | 77 | } |
73 | out += sprintf(out, "Free resources: bus numbers\n"); | 78 | out += sprintf(out, "Free resources: bus numbers\n"); |
74 | index = 11; | 79 | for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) { |
75 | res = ctrl->bus_head; | 80 | if (!pci_find_bus(pci_domain_nr(bus), busnr)) |
76 | while (res && index--) { | 81 | break; |
77 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | ||
78 | res = res->next; | ||
79 | } | 82 | } |
83 | if (busnr < bus->subordinate) | ||
84 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", | ||
85 | busnr, (bus->subordinate - busnr)); | ||
80 | 86 | ||
81 | return out - buf; | 87 | return out - buf; |
82 | } | 88 | } |
@@ -84,16 +90,16 @@ static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); | |||
84 | 90 | ||
85 | static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf) | 91 | static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf) |
86 | { | 92 | { |
87 | struct pci_dev *pci_dev; | 93 | struct pci_dev *pdev, *fdev; |
88 | struct controller *ctrl; | 94 | struct controller *ctrl; |
89 | char * out = buf; | 95 | char * out = buf; |
90 | int index; | 96 | int index; |
91 | struct pci_resource *res; | 97 | struct resource *res; |
92 | struct pci_func *new_slot; | 98 | struct pci_func *new_slot; |
93 | struct slot *slot; | 99 | struct slot *slot; |
94 | 100 | ||
95 | pci_dev = container_of (dev, struct pci_dev, dev); | 101 | pdev = container_of (dev, struct pci_dev, dev); |
96 | ctrl = pci_get_drvdata(pci_dev); | 102 | ctrl = pci_get_drvdata(pdev); |
97 | 103 | ||
98 | slot=ctrl->slot; | 104 | slot=ctrl->slot; |
99 | 105 | ||
@@ -101,34 +107,47 @@ static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char | |||
101 | new_slot = shpchp_slot_find(slot->bus, slot->device, 0); | 107 | new_slot = shpchp_slot_find(slot->bus, slot->device, 0); |
102 | if (!new_slot) | 108 | if (!new_slot) |
103 | break; | 109 | break; |
110 | fdev = new_slot->pci_dev; | ||
111 | if (!fdev) | ||
112 | break; | ||
104 | out += sprintf(out, "assigned resources: memory\n"); | 113 | out += sprintf(out, "assigned resources: memory\n"); |
105 | index = 11; | 114 | for (index=0; index <= PCI_NUM_RESOURCES; index++) { |
106 | res = new_slot->mem_head; | 115 | res = &(fdev->resource[index]); |
107 | while (res && index--) { | 116 | if (res && (res->flags & IORESOURCE_MEM) && |
108 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 117 | !(res->flags & IORESOURCE_PREFETCH)) { |
109 | res = res->next; | 118 | out += sprintf(out, |
119 | "start = %8.8lx, length = %8.8lx\n", | ||
120 | res->start, (res->end - res->start)); | ||
121 | } | ||
110 | } | 122 | } |
111 | out += sprintf(out, "assigned resources: prefetchable memory\n"); | 123 | out += sprintf(out, "assigned resources: prefetchable memory\n"); |
112 | index = 11; | 124 | for (index=0; index <= PCI_NUM_RESOURCES; index++) { |
113 | res = new_slot->p_mem_head; | 125 | res = &(fdev->resource[index]); |
114 | while (res && index--) { | 126 | if (res && (res->flags & (IORESOURCE_MEM | |
115 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 127 | IORESOURCE_PREFETCH))) { |
116 | res = res->next; | 128 | out += sprintf(out, |
129 | "start = %8.8lx, length = %8.8lx\n", | ||
130 | res->start, (res->end - res->start)); | ||
131 | } | ||
117 | } | 132 | } |
118 | out += sprintf(out, "assigned resources: IO\n"); | 133 | out += sprintf(out, "assigned resources: IO\n"); |
119 | index = 11; | 134 | for (index=0; index <= PCI_NUM_RESOURCES; index++) { |
120 | res = new_slot->io_head; | 135 | res = &(fdev->resource[index]); |
121 | while (res && index--) { | 136 | if (res && (res->flags & IORESOURCE_IO)) { |
122 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 137 | out += sprintf(out, |
123 | res = res->next; | 138 | "start = %8.8lx, length = %8.8lx\n", |
139 | res->start, (res->end - res->start)); | ||
140 | } | ||
124 | } | 141 | } |
125 | out += sprintf(out, "assigned resources: bus numbers\n"); | 142 | out += sprintf(out, "assigned resources: bus numbers\n"); |
126 | index = 11; | 143 | if (fdev->subordinate) |
127 | res = new_slot->bus_head; | 144 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", |
128 | while (res && index--) { | 145 | fdev->subordinate->secondary, |
129 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 146 | (fdev->subordinate->subordinate - |
130 | res = res->next; | 147 | fdev->subordinate->secondary)); |
131 | } | 148 | else |
149 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", | ||
150 | fdev->bus->number, 1); | ||
132 | slot=slot->next; | 151 | slot=slot->next; |
133 | } | 152 | } |
134 | 153 | ||