Merge branch 'for-linus' of git://android.git.kernel.org/kernel/tegra
[pandora-kernel.git] / arch / s390 / kernel / setup.c
index 6f63508..f5434d1 100644 (file)
@@ -102,16 +102,6 @@ EXPORT_SYMBOL(lowcore_ptr);
 
 #include <asm/setup.h>
 
-static struct resource code_resource = {
-       .name  = "Kernel code",
-       .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
-};
-
-static struct resource data_resource = {
-       .name = "Kernel data",
-       .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
-};
-
 /*
  * condev= and conmode= setup parameter.
  */
@@ -436,21 +426,43 @@ setup_lowcore(void)
        lowcore_ptr[0] = lc;
 }
 
-static void __init
-setup_resources(void)
+static struct resource code_resource = {
+       .name  = "Kernel code",
+       .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
+};
+
+static struct resource data_resource = {
+       .name = "Kernel data",
+       .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
+};
+
+static struct resource bss_resource = {
+       .name = "Kernel bss",
+       .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
+};
+
+static struct resource __initdata *standard_resources[] = {
+       &code_resource,
+       &data_resource,
+       &bss_resource,
+};
+
+static void __init setup_resources(void)
 {
-       struct resource *res, *sub_res;
-       int i;
+       struct resource *res, *std_res, *sub_res;
+       int i, j;
 
        code_resource.start = (unsigned long) &_text;
        code_resource.end = (unsigned long) &_etext - 1;
        data_resource.start = (unsigned long) &_etext;
        data_resource.end = (unsigned long) &_edata - 1;
+       bss_resource.start = (unsigned long) &__bss_start;
+       bss_resource.end = (unsigned long) &__bss_stop - 1;
 
        for (i = 0; i < MEMORY_CHUNKS; i++) {
                if (!memory_chunk[i].size)
                        continue;
-               res = alloc_bootmem_low(sizeof(struct resource));
+               res = alloc_bootmem_low(sizeof(*res));
                res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
                switch (memory_chunk[i].type) {
                case CHUNK_READ_WRITE:
@@ -464,40 +476,24 @@ setup_resources(void)
                        res->name = "reserved";
                }
                res->start = memory_chunk[i].addr;
-               res->end = memory_chunk[i].addr +  memory_chunk[i].size - 1;
+               res->end = res->start + memory_chunk[i].size - 1;
                request_resource(&iomem_resource, res);
 
-               if (code_resource.start >= res->start  &&
-                       code_resource.start <= res->end &&
-                       code_resource.end > res->end) {
-                       sub_res = alloc_bootmem_low(sizeof(struct resource));
-                       memcpy(sub_res, &code_resource,
-                               sizeof(struct resource));
-                       sub_res->end = res->end;
-                       code_resource.start = res->end + 1;
-                       request_resource(res, sub_res);
-               }
-
-               if (code_resource.start >= res->start &&
-                       code_resource.start <= res->end &&
-                       code_resource.end <= res->end)
-                       request_resource(res, &code_resource);
-
-               if (data_resource.start >= res->start &&
-                       data_resource.start <= res->end &&
-                       data_resource.end > res->end) {
-                       sub_res = alloc_bootmem_low(sizeof(struct resource));
-                       memcpy(sub_res, &data_resource,
-                               sizeof(struct resource));
-                       sub_res->end = res->end;
-                       data_resource.start = res->end + 1;
-                       request_resource(res, sub_res);
+               for (j = 0; j < ARRAY_SIZE(standard_resources); j++) {
+                       std_res = standard_resources[j];
+                       if (std_res->start < res->start ||
+                           std_res->start > res->end)
+                               continue;
+                       if (std_res->end > res->end) {
+                               sub_res = alloc_bootmem_low(sizeof(*sub_res));
+                               *sub_res = *std_res;
+                               sub_res->end = res->end;
+                               std_res->start = res->end + 1;
+                               request_resource(res, sub_res);
+                       } else {
+                               request_resource(res, std_res);
+                       }
                }
-
-               if (data_resource.start >= res->start &&
-                       data_resource.start <= res->end &&
-                       data_resource.end <= res->end)
-                       request_resource(res, &data_resource);
        }
 }
 
@@ -712,7 +708,7 @@ static void __init setup_hwcaps(void)
         * and 1ULL<<0 as bit 63. Bits 0-31 contain the same information
         * as stored by stfl, bits 32-xxx contain additional facilities.
         * How many facility words are stored depends on the number of
-        * doublewords passed to the instruction. The additional facilites
+        * doublewords passed to the instruction. The additional facilities
         * are:
         *   Bit 42: decimal floating point facility is installed
         *   Bit 44: perform floating point operation facility is installed