aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pnp/interface.c41
-rw-r--r--drivers/pnp/quirks.c13
-rw-r--r--drivers/pnp/resource.c48
-rw-r--r--drivers/pnp/system.c21
4 files changed, 60 insertions, 63 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index a608054a3e5..e9e66ed4fa3 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -248,6 +248,7 @@ 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 resource *res;
251 int i, ret; 252 int i, ret;
252 pnp_info_buffer_t *buffer; 253 pnp_info_buffer_t *buffer;
253 254
@@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
267 else 268 else
268 pnp_printf(buffer, "disabled\n"); 269 pnp_printf(buffer, "disabled\n");
269 270
270 for (i = 0; i < PNP_MAX_PORT; i++) { 271 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
271 if (pnp_port_valid(dev, i)) { 272 if (pnp_resource_valid(res)) {
272 pnp_printf(buffer, "io"); 273 pnp_printf(buffer, "io");
273 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) 274 if (res->flags & IORESOURCE_DISABLED)
274 pnp_printf(buffer, " disabled\n"); 275 pnp_printf(buffer, " disabled\n");
275 else 276 else
276 pnp_printf(buffer, " 0x%llx-0x%llx\n", 277 pnp_printf(buffer, " 0x%llx-0x%llx\n",
277 (unsigned long long) 278 (unsigned long long) res->start,
278 pnp_port_start(dev, i), 279 (unsigned long long) res->end);
279 (unsigned long long)pnp_port_end(dev,
280 i));
281 } 280 }
282 } 281 }
283 for (i = 0; i < PNP_MAX_MEM; i++) { 282 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
284 if (pnp_mem_valid(dev, i)) { 283 if (pnp_resource_valid(res)) {
285 pnp_printf(buffer, "mem"); 284 pnp_printf(buffer, "mem");
286 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) 285 if (res->flags & IORESOURCE_DISABLED)
287 pnp_printf(buffer, " disabled\n"); 286 pnp_printf(buffer, " disabled\n");
288 else 287 else
289 pnp_printf(buffer, " 0x%llx-0x%llx\n", 288 pnp_printf(buffer, " 0x%llx-0x%llx\n",
290 (unsigned long long) 289 (unsigned long long) res->start,
291 pnp_mem_start(dev, i), 290 (unsigned long long) res->end);
292 (unsigned long long)pnp_mem_end(dev,
293 i));
294 } 291 }
295 } 292 }
296 for (i = 0; i < PNP_MAX_IRQ; i++) { 293 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
297 if (pnp_irq_valid(dev, i)) { 294 if (pnp_resource_valid(res)) {
298 pnp_printf(buffer, "irq"); 295 pnp_printf(buffer, "irq");
299 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) 296 if (res->flags & IORESOURCE_DISABLED)
300 pnp_printf(buffer, " disabled\n"); 297 pnp_printf(buffer, " disabled\n");
301 else 298 else
302 pnp_printf(buffer, " %lld\n", 299 pnp_printf(buffer, " %lld\n",
303 (unsigned long long)pnp_irq(dev, i)); 300 (unsigned long long) res->start);
304 } 301 }
305 } 302 }
306 for (i = 0; i < PNP_MAX_DMA; i++) { 303 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
307 if (pnp_dma_valid(dev, i)) { 304 if (pnp_resource_valid(res)) {
308 pnp_printf(buffer, "dma"); 305 pnp_printf(buffer, "dma");
309 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) 306 if (res->flags & IORESOURCE_DISABLED)
310 pnp_printf(buffer, " disabled\n"); 307 pnp_printf(buffer, " disabled\n");
311 else 308 else
312 pnp_printf(buffer, " %lld\n", 309 pnp_printf(buffer, " %lld\n",
313 (unsigned long long)pnp_dma(dev, i)); 310 (unsigned long long) res->start);
314 } 311 }
315 } 312 }
316 ret = (buffer->curr - buf); 313 ret = (buffer->curr - buf);
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index c47dd252f44..d049a2279fe 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -138,13 +138,15 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
138 138
139 pci_start = pci_resource_start(pdev, i); 139 pci_start = pci_resource_start(pdev, i);
140 pci_end = pci_resource_end(pdev, i); 140 pci_end = pci_resource_end(pdev, i);
141 for (j = 0; j < PNP_MAX_MEM; j++) { 141 for (j = 0;
142 if (!pnp_mem_valid(dev, j) || 142 (res = pnp_get_resource(dev, IORESOURCE_MEM, j));
143 pnp_mem_len(dev, j) == 0) 143 j++) {
144 if (res->flags & IORESOURCE_UNSET ||
145 (res->start == 0 && res->end == 0))
144 continue; 146 continue;
145 147
146 pnp_start = pnp_mem_start(dev, j); 148 pnp_start = res->start;
147 pnp_end = pnp_mem_end(dev, j); 149 pnp_end = res->end;
148 150
149 /* 151 /*
150 * If the PNP region doesn't overlap the PCI 152 * If the PNP region doesn't overlap the PCI
@@ -177,7 +179,6 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
177 pci_name(pdev), i, 179 pci_name(pdev), i,
178 (unsigned long long) pci_start, 180 (unsigned long long) pci_start,
179 (unsigned long long) pci_end); 181 (unsigned long long) pci_end);
180 res = pnp_get_resource(dev, IORESOURCE_MEM, j);
181 res->flags = 0; 182 res->flags = 0;
182 } 183 }
183 } 184 }
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index b2516d62fcf..84362818fa8 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -269,9 +269,8 @@ int pnp_check_port(struct pnp_dev *dev, struct resource *res)
269 } 269 }
270 270
271 /* check for internal conflicts */ 271 /* check for internal conflicts */
272 for (i = 0; i < PNP_MAX_PORT; i++) { 272 for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
273 tres = pnp_get_resource(dev, IORESOURCE_IO, i); 273 if (tres != res && tres->flags & IORESOURCE_IO) {
274 if (tres && tres != res && tres->flags & IORESOURCE_IO) {
275 tport = &tres->start; 274 tport = &tres->start;
276 tend = &tres->end; 275 tend = &tres->end;
277 if (ranged_conflict(port, end, tport, tend)) 276 if (ranged_conflict(port, end, tport, tend))
@@ -283,9 +282,10 @@ int pnp_check_port(struct pnp_dev *dev, struct resource *res)
283 pnp_for_each_dev(tdev) { 282 pnp_for_each_dev(tdev) {
284 if (tdev == dev) 283 if (tdev == dev)
285 continue; 284 continue;
286 for (i = 0; i < PNP_MAX_PORT; i++) { 285 for (i = 0;
287 tres = pnp_get_resource(tdev, IORESOURCE_IO, i); 286 (tres = pnp_get_resource(tdev, IORESOURCE_IO, i));
288 if (tres && tres->flags & IORESOURCE_IO) { 287 i++) {
288 if (tres->flags & IORESOURCE_IO) {
289 if (cannot_compare(tres->flags)) 289 if (cannot_compare(tres->flags))
290 continue; 290 continue;
291 tport = &tres->start; 291 tport = &tres->start;
@@ -329,9 +329,8 @@ int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
329 } 329 }
330 330
331 /* check for internal conflicts */ 331 /* check for internal conflicts */
332 for (i = 0; i < PNP_MAX_MEM; i++) { 332 for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
333 tres = pnp_get_resource(dev, IORESOURCE_MEM, i); 333 if (tres != res && tres->flags & IORESOURCE_MEM) {
334 if (tres && tres != res && tres->flags & IORESOURCE_MEM) {
335 taddr = &tres->start; 334 taddr = &tres->start;
336 tend = &tres->end; 335 tend = &tres->end;
337 if (ranged_conflict(addr, end, taddr, tend)) 336 if (ranged_conflict(addr, end, taddr, tend))
@@ -343,9 +342,10 @@ int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
343 pnp_for_each_dev(tdev) { 342 pnp_for_each_dev(tdev) {
344 if (tdev == dev) 343 if (tdev == dev)
345 continue; 344 continue;
346 for (i = 0; i < PNP_MAX_MEM; i++) { 345 for (i = 0;
347 tres = pnp_get_resource(tdev, IORESOURCE_MEM, i); 346 (tres = pnp_get_resource(tdev, IORESOURCE_MEM, i));
348 if (tres && tres->flags & IORESOURCE_MEM) { 347 i++) {
348 if (tres->flags & IORESOURCE_MEM) {
349 if (cannot_compare(tres->flags)) 349 if (cannot_compare(tres->flags))
350 continue; 350 continue;
351 taddr = &tres->start; 351 taddr = &tres->start;
@@ -388,9 +388,8 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
388 } 388 }
389 389
390 /* check for internal conflicts */ 390 /* check for internal conflicts */
391 for (i = 0; i < PNP_MAX_IRQ; i++) { 391 for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
392 tres = pnp_get_resource(dev, IORESOURCE_IRQ, i); 392 if (tres != res && tres->flags & IORESOURCE_IRQ) {
393 if (tres && tres != res && tres->flags & IORESOURCE_IRQ) {
394 if (tres->start == *irq) 393 if (tres->start == *irq)
395 return 0; 394 return 0;
396 } 395 }
@@ -422,9 +421,10 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
422 pnp_for_each_dev(tdev) { 421 pnp_for_each_dev(tdev) {
423 if (tdev == dev) 422 if (tdev == dev)
424 continue; 423 continue;
425 for (i = 0; i < PNP_MAX_IRQ; i++) { 424 for (i = 0;
426 tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i); 425 (tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i));
427 if (tres && tres->flags & IORESOURCE_IRQ) { 426 i++) {
427 if (tres->flags & IORESOURCE_IRQ) {
428 if (cannot_compare(tres->flags)) 428 if (cannot_compare(tres->flags))
429 continue; 429 continue;
430 if (tres->start == *irq) 430 if (tres->start == *irq)
@@ -461,9 +461,8 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
461 } 461 }
462 462
463 /* check for internal conflicts */ 463 /* check for internal conflicts */
464 for (i = 0; i < PNP_MAX_DMA; i++) { 464 for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
465 tres = pnp_get_resource(dev, IORESOURCE_DMA, i); 465 if (tres != res && tres->flags & IORESOURCE_DMA) {
466 if (tres && tres != res && tres->flags & IORESOURCE_DMA) {
467 if (tres->start == *dma) 466 if (tres->start == *dma)
468 return 0; 467 return 0;
469 } 468 }
@@ -481,9 +480,10 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
481 pnp_for_each_dev(tdev) { 480 pnp_for_each_dev(tdev) {
482 if (tdev == dev) 481 if (tdev == dev)
483 continue; 482 continue;
484 for (i = 0; i < PNP_MAX_DMA; i++) { 483 for (i = 0;
485 tres = pnp_get_resource(tdev, IORESOURCE_DMA, i); 484 (tres = pnp_get_resource(tdev, IORESOURCE_DMA, i));
486 if (tres && tres->flags & IORESOURCE_DMA) { 485 i++) {
486 if (tres->flags & IORESOURCE_DMA) {
487 if (cannot_compare(tres->flags)) 487 if (cannot_compare(tres->flags))
488 continue; 488 continue;
489 if (tres->start == *dma) 489 if (tres->start == *dma)
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index 55c4563986b..9c2496dbeee 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -56,14 +56,15 @@ static void reserve_range(struct pnp_dev *dev, resource_size_t start,
56 56
57static void reserve_resources_of_dev(struct pnp_dev *dev) 57static void reserve_resources_of_dev(struct pnp_dev *dev)
58{ 58{
59 struct resource *res;
59 int i; 60 int i;
60 61
61 for (i = 0; i < PNP_MAX_PORT; i++) { 62 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
62 if (!pnp_port_valid(dev, i)) 63 if (res->flags & IORESOURCE_UNSET)
63 continue; 64 continue;
64 if (pnp_port_start(dev, i) == 0) 65 if (res->start == 0)
65 continue; /* disabled */ 66 continue; /* disabled */
66 if (pnp_port_start(dev, i) < 0x100) 67 if (res->start < 0x100)
67 /* 68 /*
68 * Below 0x100 is only standard PC hardware 69 * Below 0x100 is only standard PC hardware
69 * (pics, kbd, timer, dma, ...) 70 * (pics, kbd, timer, dma, ...)
@@ -73,19 +74,17 @@ static void reserve_resources_of_dev(struct pnp_dev *dev)
73 * So, do nothing 74 * So, do nothing
74 */ 75 */
75 continue; 76 continue;
76 if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) 77 if (res->end < res->start)
77 continue; /* invalid */ 78 continue; /* invalid */
78 79
79 reserve_range(dev, pnp_port_start(dev, i), 80 reserve_range(dev, res->start, res->end, 1);
80 pnp_port_end(dev, i), 1);
81 } 81 }
82 82
83 for (i = 0; i < PNP_MAX_MEM; i++) { 83 for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
84 if (!pnp_mem_valid(dev, i)) 84 if (res->flags & IORESOURCE_UNSET)
85 continue; 85 continue;
86 86
87 reserve_range(dev, pnp_mem_start(dev, i), 87 reserve_range(dev, res->start, res->end, 0);
88 pnp_mem_end(dev, i), 0);
89 } 88 }
90} 89}
91 90