arch: Move initrd= parsing into do_mounts_initrd.c
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 5 Nov 2018 22:54:31 +0000 (14:54 -0800)
committerRob Herring <robh@kernel.org>
Mon, 26 Nov 2018 21:50:45 +0000 (15:50 -0600)
ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd="
command line parameter to allow specifying the physical address and size
of an initrd. Move that parsing into init/do_mounts_initrd.c such that
we no longer duplicate that logic.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
arch/arc/mm/init.c
arch/arm/mm/init.c
arch/arm64/mm/init.c
arch/unicore32/mm/init.c
init/do_mounts_initrd.c

index f8fe5668b30fd98412c8fbf45433d3b8718158d4..43bf4c3a1290d818578bfdcda5fefaf76df27810 100644 (file)
@@ -78,24 +78,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
                base, TO_MB(size), !in_use ? "Not used":"");
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-       unsigned long start, size;
-       char *endp;
-
-       start = memparse(p, &endp);
-       if (*endp == ',') {
-               size = memparse(endp + 1, NULL);
-
-               initrd_start = (unsigned long)__va(start);
-               initrd_end = (unsigned long)__va(start + size);
-       }
-       return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 /*
  * First memory setup routine called from setup_arch()
  * 1. setup swapper's mm @init_mm
@@ -140,8 +122,11 @@ void __init setup_arch_memory(void)
        memblock_reserve(low_mem_start, __pa(_end) - low_mem_start);
 
 #ifdef CONFIG_BLK_DEV_INITRD
-       if (initrd_start)
-               memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
+       if (phys_initrd_size) {
+               memblock_reserve(phys_initrd_start, phys_initrd_size);
+               initrd_start = (unsigned long)__va(phys_initrd_start);
+               initrd_end = initrd_start + phys_initrd_size;
+       }
 #endif
 
        early_init_fdt_reserve_self();
index a3b6f1f1cbaf6c5cd6958a0f129147d89671ac7e..478ea8b7db877ae7426ce55d1b61e616bb6dad4e 100644 (file)
@@ -51,23 +51,6 @@ unsigned long __init __clear_cr(unsigned long mask)
 #endif
 
 #ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-       phys_addr_t start;
-       unsigned long size;
-       char *endp;
-
-       start = memparse(p, &endp);
-       if (*endp == ',') {
-               size = memparse(endp + 1, NULL);
-
-               phys_initrd_start = start;
-               phys_initrd_size = size;
-       }
-       return 0;
-}
-early_param("initrd", early_initrd);
-
 static int __init parse_tag_initrd(const struct tag *tag)
 {
        pr_warn("ATAG_INITRD is deprecated; "
index a66ffcde5f13133c4b58b3dfb9b502d973469278..7474093363bccb8cea3b342c51e516ee5f64d6bf 100644 (file)
 s64 memstart_addr __ro_after_init = -1;
 phys_addr_t arm64_dma_phys_limit __ro_after_init;
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-       unsigned long start, size;
-       char *endp;
-
-       start = memparse(p, &endp);
-       if (*endp == ',') {
-               size = memparse(endp + 1, NULL);
-
-               phys_initrd_start = start;
-               phys_initrd_size = size;
-       }
-       return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 #ifdef CONFIG_KEXEC_CORE
 /*
  * reserve_crashkernel() - reserves memory for crash kernel
index 02aa2c0b295e2763d3eaf22a35a26ad781712671..85ef2c62409034ffef4fe79e3fffca0fc5d4d73e 100644 (file)
 
 #include "mm.h"
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-       unsigned long start, size;
-       char *endp;
-
-       start = memparse(p, &endp);
-       if (*endp == ',') {
-               size = memparse(endp + 1, NULL);
-
-               phys_initrd_start = start;
-               phys_initrd_size = size;
-       }
-       return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 /*
  * This keeps memory configuration data used by a couple memory
  * initialization functions, as well as show_mem() for the skipping
index 45865b72f4eaa65ab898d296488ac64c72150345..732d21f4a637cf45f0cca345b36a5e7c64b64331 100644 (file)
@@ -27,6 +27,23 @@ static int __init no_initrd(char *str)
 
 __setup("noinitrd", no_initrd);
 
+static int __init early_initrd(char *p)
+{
+       phys_addr_t start;
+       unsigned long size;
+       char *endp;
+
+       start = memparse(p, &endp);
+       if (*endp == ',') {
+               size = memparse(endp + 1, NULL);
+
+               phys_initrd_start = start;
+               phys_initrd_size = size;
+       }
+       return 0;
+}
+early_param("initrd", early_initrd);
+
 static int init_linuxrc(struct subprocess_info *info, struct cred *new)
 {
        ksys_unshare(CLONE_FS | CLONE_FILES);