diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-06-27 18:57:00 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2008-07-16 17:27:06 -0400 |
commit | f61ed7e32d2d6a0a8c3c101da513ccedd542e14d (patch) | |
tree | 6a397ad9c74e3359f6c7f40857ca424ca701b027 /drivers | |
parent | 25d39c39d82d062f4be685146abd054a3bafdf12 (diff) |
PNP: dont sort by type in /sys/.../resources
Rather than stepping through all IO resources, then stepping through
all MMIO resources, etc., we can just iterate over the resource list
once directly.
This can change the order in /sys, e.g.,
# cat /sys/devices/pnp0/00:07/resources # OLD
state = active
io 0x3f8-0x3ff
irq 4
# cat /sys/devices/pnp0/00:07/resources # NEW
state = active
irq 4
io 0x3f8-0x3ff
The old code artificially sorted resources by type; the new code
just lists them in the order we read them from the ISAPNP hardware
or the BIOS.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/interface.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 7fc86bbed88e..674e8ba0377f 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -248,8 +248,9 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, | |||
248 | char *buf) | 248 | char *buf) |
249 | { | 249 | { |
250 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 250 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
251 | struct pnp_resource *pnp_res; | ||
251 | struct resource *res; | 252 | struct resource *res; |
252 | int i, ret; | 253 | int ret; |
253 | pnp_info_buffer_t *buffer; | 254 | pnp_info_buffer_t *buffer; |
254 | 255 | ||
255 | if (!dev) | 256 | if (!dev) |
@@ -262,46 +263,33 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, | |||
262 | buffer->buffer = buf; | 263 | buffer->buffer = buf; |
263 | buffer->curr = buffer->buffer; | 264 | buffer->curr = buffer->buffer; |
264 | 265 | ||
265 | pnp_printf(buffer, "state = "); | 266 | pnp_printf(buffer, "state = %s\n", dev->active ? "active" : "disabled"); |
266 | if (dev->active) | ||
267 | pnp_printf(buffer, "active\n"); | ||
268 | else | ||
269 | pnp_printf(buffer, "disabled\n"); | ||
270 | 267 | ||
271 | for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) { | 268 | list_for_each_entry(pnp_res, &dev->resources, list) { |
272 | pnp_printf(buffer, "io"); | 269 | res = &pnp_res->res; |
273 | if (res->flags & IORESOURCE_DISABLED) | 270 | |
274 | pnp_printf(buffer, " disabled\n"); | 271 | pnp_printf(buffer, pnp_resource_type_name(res)); |
275 | else | 272 | |
276 | pnp_printf(buffer, " 0x%llx-0x%llx\n", | 273 | if (res->flags & IORESOURCE_DISABLED) { |
277 | (unsigned long long) res->start, | ||
278 | (unsigned long long) res->end); | ||
279 | } | ||
280 | for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) { | ||
281 | pnp_printf(buffer, "mem"); | ||
282 | if (res->flags & IORESOURCE_DISABLED) | ||
283 | pnp_printf(buffer, " disabled\n"); | 274 | pnp_printf(buffer, " disabled\n"); |
284 | else | 275 | continue; |
285 | pnp_printf(buffer, " 0x%llx-0x%llx\n", | 276 | } |
277 | |||
278 | switch (pnp_resource_type(res)) { | ||
279 | case IORESOURCE_IO: | ||
280 | case IORESOURCE_MEM: | ||
281 | pnp_printf(buffer, " %#llx-%#llx\n", | ||
286 | (unsigned long long) res->start, | 282 | (unsigned long long) res->start, |
287 | (unsigned long long) res->end); | 283 | (unsigned long long) res->end); |
288 | } | 284 | break; |
289 | for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) { | 285 | case IORESOURCE_IRQ: |
290 | pnp_printf(buffer, "irq"); | 286 | case IORESOURCE_DMA: |
291 | if (res->flags & IORESOURCE_DISABLED) | ||
292 | pnp_printf(buffer, " disabled\n"); | ||
293 | else | ||
294 | pnp_printf(buffer, " %lld\n", | ||
295 | (unsigned long long) res->start); | ||
296 | } | ||
297 | for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) { | ||
298 | pnp_printf(buffer, "dma"); | ||
299 | if (res->flags & IORESOURCE_DISABLED) | ||
300 | pnp_printf(buffer, " disabled\n"); | ||
301 | else | ||
302 | pnp_printf(buffer, " %lld\n", | 287 | pnp_printf(buffer, " %lld\n", |
303 | (unsigned long long) res->start); | 288 | (unsigned long long) res->start); |
289 | break; | ||
290 | } | ||
304 | } | 291 | } |
292 | |||
305 | ret = (buffer->curr - buf); | 293 | ret = (buffer->curr - buf); |
306 | kfree(buffer); | 294 | kfree(buffer); |
307 | return ret; | 295 | return ret; |