aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-04-28 18:34:25 -0400
committerLen Brown <len.brown@intel.com>2008-04-29 03:22:26 -0400
commitf6505fef18644557f732468c1f22f84560d8a819 (patch)
tree942bf646b502369e3f8e8f398265d0872e8d3a0c /drivers/pnp
parent7e2cf31f1c97ac14b6d9dc5f1ce9e1e01aef9c18 (diff)
PNP: convert assign, interface to use pnp_get_resource(), not pnp_resource_table
This removes more direct references to pnp_resource_table from the pnp_assign_resources() path and the /sys user interface path. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/interface.c28
-rw-r--r--drivers/pnp/manager.c20
-rw-r--r--drivers/pnp/support.c16
3 files changed, 32 insertions, 32 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 1801df3db1e8..a608054a3e53 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -383,7 +383,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
383 buf += 2; 383 buf += 2;
384 while (isspace(*buf)) 384 while (isspace(*buf))
385 ++buf; 385 ++buf;
386 res = &dev->res.port_resource[nport]; 386 res = pnp_get_resource(dev, IORESOURCE_IO,
387 nport);
388 if (!res)
389 break;
387 res->start = simple_strtoul(buf, &buf, 0); 390 res->start = simple_strtoul(buf, &buf, 0);
388 while (isspace(*buf)) 391 while (isspace(*buf))
389 ++buf; 392 ++buf;
@@ -396,15 +399,16 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
396 res->end = res->start; 399 res->end = res->start;
397 res->flags = IORESOURCE_IO; 400 res->flags = IORESOURCE_IO;
398 nport++; 401 nport++;
399 if (nport >= PNP_MAX_PORT)
400 break;
401 continue; 402 continue;
402 } 403 }
403 if (!strnicmp(buf, "mem", 3)) { 404 if (!strnicmp(buf, "mem", 3)) {
404 buf += 3; 405 buf += 3;
405 while (isspace(*buf)) 406 while (isspace(*buf))
406 ++buf; 407 ++buf;
407 res = &dev->res.mem_resource[nmem]; 408 res = pnp_get_resource(dev, IORESOURCE_MEM,
409 nmem);
410 if (!res)
411 break;
408 res->start = simple_strtoul(buf, &buf, 0); 412 res->start = simple_strtoul(buf, &buf, 0);
409 while (isspace(*buf)) 413 while (isspace(*buf))
410 ++buf; 414 ++buf;
@@ -417,34 +421,34 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
417 res->end = res->start; 421 res->end = res->start;
418 res->flags = IORESOURCE_MEM; 422 res->flags = IORESOURCE_MEM;
419 nmem++; 423 nmem++;
420 if (nmem >= PNP_MAX_MEM)
421 break;
422 continue; 424 continue;
423 } 425 }
424 if (!strnicmp(buf, "irq", 3)) { 426 if (!strnicmp(buf, "irq", 3)) {
425 buf += 3; 427 buf += 3;
426 while (isspace(*buf)) 428 while (isspace(*buf))
427 ++buf; 429 ++buf;
428 res = &dev->res.irq_resource[nirq]; 430 res = pnp_get_resource(dev, IORESOURCE_IRQ,
431 nirq);
432 if (!res)
433 break;
429 res->start = res->end = 434 res->start = res->end =
430 simple_strtoul(buf, &buf, 0); 435 simple_strtoul(buf, &buf, 0);
431 res->flags = IORESOURCE_IRQ; 436 res->flags = IORESOURCE_IRQ;
432 nirq++; 437 nirq++;
433 if (nirq >= PNP_MAX_IRQ)
434 break;
435 continue; 438 continue;
436 } 439 }
437 if (!strnicmp(buf, "dma", 3)) { 440 if (!strnicmp(buf, "dma", 3)) {
438 buf += 3; 441 buf += 3;
439 while (isspace(*buf)) 442 while (isspace(*buf))
440 ++buf; 443 ++buf;
441 res = &dev->res.dma_resource[ndma]; 444 res = pnp_get_resource(dev, IORESOURCE_DMA,
445 ndma);
446 if (!res)
447 break;
442 res->start = res->end = 448 res->start = res->end =
443 simple_strtoul(buf, &buf, 0); 449 simple_strtoul(buf, &buf, 0);
444 res->flags = IORESOURCE_DMA; 450 res->flags = IORESOURCE_DMA;
445 ndma++; 451 ndma++;
446 if (ndma >= PNP_MAX_DMA)
447 break;
448 continue; 452 continue;
449 } 453 }
450 break; 454 break;
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 08865292fc95..7c5ebddfc6af 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -21,14 +21,13 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
21{ 21{
22 struct resource *res; 22 struct resource *res;
23 23
24 if (idx >= PNP_MAX_PORT) { 24 res = pnp_get_resource(dev, IORESOURCE_IO, idx);
25 if (!res) {
25 dev_err(&dev->dev, "too many I/O port resources\n"); 26 dev_err(&dev->dev, "too many I/O port resources\n");
26 /* pretend we were successful so at least the manager won't try again */ 27 /* pretend we were successful so at least the manager won't try again */
27 return 1; 28 return 1;
28 } 29 }
29 30
30 res = &dev->res.port_resource[idx];
31
32 /* check if this resource has been manually set, if so skip */ 31 /* check if this resource has been manually set, if so skip */
33 if (!(res->flags & IORESOURCE_AUTO)) { 32 if (!(res->flags & IORESOURCE_AUTO)) {
34 dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx " 33 dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx "
@@ -68,14 +67,13 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
68{ 67{
69 struct resource *res; 68 struct resource *res;
70 69
71 if (idx >= PNP_MAX_MEM) { 70 res = pnp_get_resource(dev, IORESOURCE_MEM, idx);
71 if (!res) {
72 dev_err(&dev->dev, "too many memory resources\n"); 72 dev_err(&dev->dev, "too many memory resources\n");
73 /* pretend we were successful so at least the manager won't try again */ 73 /* pretend we were successful so at least the manager won't try again */
74 return 1; 74 return 1;
75 } 75 }
76 76
77 res = &dev->res.mem_resource[idx];
78
79 /* check if this resource has been manually set, if so skip */ 77 /* check if this resource has been manually set, if so skip */
80 if (!(res->flags & IORESOURCE_AUTO)) { 78 if (!(res->flags & IORESOURCE_AUTO)) {
81 dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx " 79 dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx "
@@ -131,14 +129,13 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
131 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 129 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
132 }; 130 };
133 131
134 if (idx >= PNP_MAX_IRQ) { 132 res = pnp_get_resource(dev, IORESOURCE_IRQ, idx);
133 if (!res) {
135 dev_err(&dev->dev, "too many IRQ resources\n"); 134 dev_err(&dev->dev, "too many IRQ resources\n");
136 /* pretend we were successful so at least the manager won't try again */ 135 /* pretend we were successful so at least the manager won't try again */
137 return 1; 136 return 1;
138 } 137 }
139 138
140 res = &dev->res.irq_resource[idx];
141
142 /* check if this resource has been manually set, if so skip */ 139 /* check if this resource has been manually set, if so skip */
143 if (!(res->flags & IORESOURCE_AUTO)) { 140 if (!(res->flags & IORESOURCE_AUTO)) {
144 dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n", 141 dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n",
@@ -188,13 +185,12 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
188 1, 3, 5, 6, 7, 0, 2, 4 185 1, 3, 5, 6, 7, 0, 2, 4
189 }; 186 };
190 187
191 if (idx >= PNP_MAX_DMA) { 188 res = pnp_get_resource(dev, IORESOURCE_DMA, idx);
189 if (!res) {
192 dev_err(&dev->dev, "too many DMA resources\n"); 190 dev_err(&dev->dev, "too many DMA resources\n");
193 return; 191 return;
194 } 192 }
195 193
196 res = &dev->res.dma_resource[idx];
197
198 /* check if this resource has been manually set, if so skip */ 194 /* check if this resource has been manually set, if so skip */
199 if (!(res->flags & IORESOURCE_AUTO)) { 195 if (!(res->flags & IORESOURCE_AUTO)) {
200 dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n", 196 dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n",
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index 3aeb154e27d6..3eba85ed729c 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -61,27 +61,27 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
61 dev_dbg(&dev->dev, "current resources: %s\n", desc); 61 dev_dbg(&dev->dev, "current resources: %s\n", desc);
62 62
63 for (i = 0; i < PNP_MAX_IRQ; i++) { 63 for (i = 0; i < PNP_MAX_IRQ; i++) {
64 res = &dev->res.irq_resource[i]; 64 res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
65 if (!(res->flags & IORESOURCE_UNSET)) 65 if (res && !(res->flags & IORESOURCE_UNSET))
66 dev_dbg(&dev->dev, " irq %lld flags %#lx\n", 66 dev_dbg(&dev->dev, " irq %lld flags %#lx\n",
67 (unsigned long long) res->start, res->flags); 67 (unsigned long long) res->start, res->flags);
68 } 68 }
69 for (i = 0; i < PNP_MAX_DMA; i++) { 69 for (i = 0; i < PNP_MAX_DMA; i++) {
70 res = &dev->res.dma_resource[i]; 70 res = pnp_get_resource(dev, IORESOURCE_DMA, i);
71 if (!(res->flags & IORESOURCE_UNSET)) 71 if (res && !(res->flags & IORESOURCE_UNSET))
72 dev_dbg(&dev->dev, " dma %lld flags %#lx\n", 72 dev_dbg(&dev->dev, " dma %lld flags %#lx\n",
73 (unsigned long long) res->start, res->flags); 73 (unsigned long long) res->start, res->flags);
74 } 74 }
75 for (i = 0; i < PNP_MAX_PORT; i++) { 75 for (i = 0; i < PNP_MAX_PORT; i++) {
76 res = &dev->res.port_resource[i]; 76 res = pnp_get_resource(dev, IORESOURCE_IO, i);
77 if (!(res->flags & IORESOURCE_UNSET)) 77 if (res && !(res->flags & IORESOURCE_UNSET))
78 dev_dbg(&dev->dev, " io %#llx-%#llx flags %#lx\n", 78 dev_dbg(&dev->dev, " io %#llx-%#llx flags %#lx\n",
79 (unsigned long long) res->start, 79 (unsigned long long) res->start,
80 (unsigned long long) res->end, res->flags); 80 (unsigned long long) res->end, res->flags);
81 } 81 }
82 for (i = 0; i < PNP_MAX_MEM; i++) { 82 for (i = 0; i < PNP_MAX_MEM; i++) {
83 res = &dev->res.mem_resource[i]; 83 res = pnp_get_resource(dev, IORESOURCE_MEM, i);
84 if (!(res->flags & IORESOURCE_UNSET)) 84 if (res && !(res->flags & IORESOURCE_UNSET))
85 dev_dbg(&dev->dev, " mem %#llx-%#llx flags %#lx\n", 85 dev_dbg(&dev->dev, " mem %#llx-%#llx flags %#lx\n",
86 (unsigned long long) res->start, 86 (unsigned long long) res->start,
87 (unsigned long long) res->end, res->flags); 87 (unsigned long long) res->end, res->flags);