diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:34:20 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:25 -0400 |
commit | 470feb113a23de365b6051efde0d69de86d9d2f8 (patch) | |
tree | 046672a3e12f41d0ef2fd8ffbe82650d7f26ee2d /drivers | |
parent | 30c016a0c8d2aae10be6a87bb98f0e85db8b09d5 (diff) |
PNP: reduce redundancy in pnp_set_current_resources()
Use a temporary "res" pointer to replace repeated lookups in
the pnp resource tables.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-By: Rene Herman <rene.herman@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/interface.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index cdc3ecfde6ef..1801df3db1e8 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -323,6 +323,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
323 | const char *ubuf, size_t count) | 323 | const char *ubuf, size_t count) |
324 | { | 324 | { |
325 | struct pnp_dev *dev = to_pnp_dev(dmdev); | 325 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
326 | struct resource *res; | ||
326 | char *buf = (void *)ubuf; | 327 | char *buf = (void *)ubuf; |
327 | int retval = 0; | 328 | int retval = 0; |
328 | 329 | ||
@@ -382,21 +383,18 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
382 | buf += 2; | 383 | buf += 2; |
383 | while (isspace(*buf)) | 384 | while (isspace(*buf)) |
384 | ++buf; | 385 | ++buf; |
385 | dev->res.port_resource[nport].start = | 386 | res = &dev->res.port_resource[nport]; |
386 | simple_strtoul(buf, &buf, 0); | 387 | res->start = simple_strtoul(buf, &buf, 0); |
387 | while (isspace(*buf)) | 388 | while (isspace(*buf)) |
388 | ++buf; | 389 | ++buf; |
389 | if (*buf == '-') { | 390 | if (*buf == '-') { |
390 | buf += 1; | 391 | buf += 1; |
391 | while (isspace(*buf)) | 392 | while (isspace(*buf)) |
392 | ++buf; | 393 | ++buf; |
393 | dev->res.port_resource[nport].end = | 394 | res->end = simple_strtoul(buf, &buf, 0); |
394 | simple_strtoul(buf, &buf, 0); | ||
395 | } else | 395 | } else |
396 | dev->res.port_resource[nport].end = | 396 | res->end = res->start; |
397 | dev->res.port_resource[nport].start; | 397 | res->flags = IORESOURCE_IO; |
398 | dev->res.port_resource[nport].flags = | ||
399 | IORESOURCE_IO; | ||
400 | nport++; | 398 | nport++; |
401 | if (nport >= PNP_MAX_PORT) | 399 | if (nport >= PNP_MAX_PORT) |
402 | break; | 400 | break; |
@@ -406,21 +404,18 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
406 | buf += 3; | 404 | buf += 3; |
407 | while (isspace(*buf)) | 405 | while (isspace(*buf)) |
408 | ++buf; | 406 | ++buf; |
409 | dev->res.mem_resource[nmem].start = | 407 | res = &dev->res.mem_resource[nmem]; |
410 | simple_strtoul(buf, &buf, 0); | 408 | res->start = simple_strtoul(buf, &buf, 0); |
411 | while (isspace(*buf)) | 409 | while (isspace(*buf)) |
412 | ++buf; | 410 | ++buf; |
413 | if (*buf == '-') { | 411 | if (*buf == '-') { |
414 | buf += 1; | 412 | buf += 1; |
415 | while (isspace(*buf)) | 413 | while (isspace(*buf)) |
416 | ++buf; | 414 | ++buf; |
417 | dev->res.mem_resource[nmem].end = | 415 | res->end = simple_strtoul(buf, &buf, 0); |
418 | simple_strtoul(buf, &buf, 0); | ||
419 | } else | 416 | } else |
420 | dev->res.mem_resource[nmem].end = | 417 | res->end = res->start; |
421 | dev->res.mem_resource[nmem].start; | 418 | res->flags = IORESOURCE_MEM; |
422 | dev->res.mem_resource[nmem].flags = | ||
423 | IORESOURCE_MEM; | ||
424 | nmem++; | 419 | nmem++; |
425 | if (nmem >= PNP_MAX_MEM) | 420 | if (nmem >= PNP_MAX_MEM) |
426 | break; | 421 | break; |
@@ -430,11 +425,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
430 | buf += 3; | 425 | buf += 3; |
431 | while (isspace(*buf)) | 426 | while (isspace(*buf)) |
432 | ++buf; | 427 | ++buf; |
433 | dev->res.irq_resource[nirq].start = | 428 | res = &dev->res.irq_resource[nirq]; |
434 | dev->res.irq_resource[nirq].end = | 429 | res->start = res->end = |
435 | simple_strtoul(buf, &buf, 0); | 430 | simple_strtoul(buf, &buf, 0); |
436 | dev->res.irq_resource[nirq].flags = | 431 | res->flags = IORESOURCE_IRQ; |
437 | IORESOURCE_IRQ; | ||
438 | nirq++; | 432 | nirq++; |
439 | if (nirq >= PNP_MAX_IRQ) | 433 | if (nirq >= PNP_MAX_IRQ) |
440 | break; | 434 | break; |
@@ -444,11 +438,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
444 | buf += 3; | 438 | buf += 3; |
445 | while (isspace(*buf)) | 439 | while (isspace(*buf)) |
446 | ++buf; | 440 | ++buf; |
447 | dev->res.dma_resource[ndma].start = | 441 | res = &dev->res.dma_resource[ndma]; |
448 | dev->res.dma_resource[ndma].end = | 442 | res->start = res->end = |
449 | simple_strtoul(buf, &buf, 0); | 443 | simple_strtoul(buf, &buf, 0); |
450 | dev->res.dma_resource[ndma].flags = | 444 | res->flags = IORESOURCE_DMA; |
451 | IORESOURCE_DMA; | ||
452 | ndma++; | 445 | ndma++; |
453 | if (ndma >= PNP_MAX_DMA) | 446 | if (ndma >= PNP_MAX_DMA) |
454 | break; | 447 | break; |