diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2011-03-23 05:15:59 -0400 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2011-03-23 05:15:59 -0400 |
commit | 71189284e61fd818547430186f524c1db54fb7c7 (patch) | |
tree | 794ed7c59ef243e9f3a0973a80567399c4a04431 /arch/s390/kernel | |
parent | d0d2e31af691ed3dbb4e556bf939b86ef745e6a3 (diff) |
[S390] setup: simplify setup_resources()
Simplify setup_resources() and make it more generic. That way it is
easier to add additional resources.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/setup.c | 80 |
1 files changed, 34 insertions, 46 deletions
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 6f6350826c81..455345104c8c 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -102,16 +102,6 @@ EXPORT_SYMBOL(lowcore_ptr); | |||
102 | 102 | ||
103 | #include <asm/setup.h> | 103 | #include <asm/setup.h> |
104 | 104 | ||
105 | static struct resource code_resource = { | ||
106 | .name = "Kernel code", | ||
107 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, | ||
108 | }; | ||
109 | |||
110 | static struct resource data_resource = { | ||
111 | .name = "Kernel data", | ||
112 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, | ||
113 | }; | ||
114 | |||
115 | /* | 105 | /* |
116 | * condev= and conmode= setup parameter. | 106 | * condev= and conmode= setup parameter. |
117 | */ | 107 | */ |
@@ -436,11 +426,25 @@ setup_lowcore(void) | |||
436 | lowcore_ptr[0] = lc; | 426 | lowcore_ptr[0] = lc; |
437 | } | 427 | } |
438 | 428 | ||
439 | static void __init | 429 | static struct resource code_resource = { |
440 | setup_resources(void) | 430 | .name = "Kernel code", |
431 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, | ||
432 | }; | ||
433 | |||
434 | static struct resource data_resource = { | ||
435 | .name = "Kernel data", | ||
436 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, | ||
437 | }; | ||
438 | |||
439 | static struct resource __initdata *standard_resources[] = { | ||
440 | &code_resource, | ||
441 | &data_resource, | ||
442 | }; | ||
443 | |||
444 | static void __init setup_resources(void) | ||
441 | { | 445 | { |
442 | struct resource *res, *sub_res; | 446 | struct resource *res, *std_res, *sub_res; |
443 | int i; | 447 | int i, j; |
444 | 448 | ||
445 | code_resource.start = (unsigned long) &_text; | 449 | code_resource.start = (unsigned long) &_text; |
446 | code_resource.end = (unsigned long) &_etext - 1; | 450 | code_resource.end = (unsigned long) &_etext - 1; |
@@ -450,7 +454,7 @@ setup_resources(void) | |||
450 | for (i = 0; i < MEMORY_CHUNKS; i++) { | 454 | for (i = 0; i < MEMORY_CHUNKS; i++) { |
451 | if (!memory_chunk[i].size) | 455 | if (!memory_chunk[i].size) |
452 | continue; | 456 | continue; |
453 | res = alloc_bootmem_low(sizeof(struct resource)); | 457 | res = alloc_bootmem_low(sizeof(*res)); |
454 | res->flags = IORESOURCE_BUSY | IORESOURCE_MEM; | 458 | res->flags = IORESOURCE_BUSY | IORESOURCE_MEM; |
455 | switch (memory_chunk[i].type) { | 459 | switch (memory_chunk[i].type) { |
456 | case CHUNK_READ_WRITE: | 460 | case CHUNK_READ_WRITE: |
@@ -464,40 +468,24 @@ setup_resources(void) | |||
464 | res->name = "reserved"; | 468 | res->name = "reserved"; |
465 | } | 469 | } |
466 | res->start = memory_chunk[i].addr; | 470 | res->start = memory_chunk[i].addr; |
467 | res->end = memory_chunk[i].addr + memory_chunk[i].size - 1; | 471 | res->end = res->start + memory_chunk[i].size - 1; |
468 | request_resource(&iomem_resource, res); | 472 | request_resource(&iomem_resource, res); |
469 | 473 | ||
470 | if (code_resource.start >= res->start && | 474 | for (j = 0; j < ARRAY_SIZE(standard_resources); j++) { |
471 | code_resource.start <= res->end && | 475 | std_res = standard_resources[j]; |
472 | code_resource.end > res->end) { | 476 | if (std_res->start < res->start || |
473 | sub_res = alloc_bootmem_low(sizeof(struct resource)); | 477 | std_res->start > res->end) |
474 | memcpy(sub_res, &code_resource, | 478 | continue; |
475 | sizeof(struct resource)); | 479 | if (std_res->end > res->end) { |
476 | sub_res->end = res->end; | 480 | sub_res = alloc_bootmem_low(sizeof(*sub_res)); |
477 | code_resource.start = res->end + 1; | 481 | *sub_res = *std_res; |
478 | request_resource(res, sub_res); | 482 | sub_res->end = res->end; |
479 | } | 483 | std_res->start = res->end + 1; |
480 | 484 | request_resource(res, sub_res); | |
481 | if (code_resource.start >= res->start && | 485 | } else { |
482 | code_resource.start <= res->end && | 486 | request_resource(res, std_res); |
483 | code_resource.end <= res->end) | 487 | } |
484 | request_resource(res, &code_resource); | ||
485 | |||
486 | if (data_resource.start >= res->start && | ||
487 | data_resource.start <= res->end && | ||
488 | data_resource.end > res->end) { | ||
489 | sub_res = alloc_bootmem_low(sizeof(struct resource)); | ||
490 | memcpy(sub_res, &data_resource, | ||
491 | sizeof(struct resource)); | ||
492 | sub_res->end = res->end; | ||
493 | data_resource.start = res->end + 1; | ||
494 | request_resource(res, sub_res); | ||
495 | } | 488 | } |
496 | |||
497 | if (data_resource.start >= res->start && | ||
498 | data_resource.start <= res->end && | ||
499 | data_resource.end <= res->end) | ||
500 | request_resource(res, &data_resource); | ||
501 | } | 489 | } |
502 | } | 490 | } |
503 | 491 | ||