Skip to content

Commit 229c55c

Browse files
ffainellirobherring
authored andcommitted
arch: Move initrd= parsing into do_mounts_initrd.c
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>
1 parent cdbc848 commit 229c55c

File tree

5 files changed

+22
-73
lines changed

5 files changed

+22
-73
lines changed

arch/arc/mm/init.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
7878
base, TO_MB(size), !in_use ? "Not used":"");
7979
}
8080

81-
#ifdef CONFIG_BLK_DEV_INITRD
82-
static int __init early_initrd(char *p)
83-
{
84-
unsigned long start, size;
85-
char *endp;
86-
87-
start = memparse(p, &endp);
88-
if (*endp == ',') {
89-
size = memparse(endp + 1, NULL);
90-
91-
initrd_start = (unsigned long)__va(start);
92-
initrd_end = (unsigned long)__va(start + size);
93-
}
94-
return 0;
95-
}
96-
early_param("initrd", early_initrd);
97-
#endif
98-
9981
/*
10082
* First memory setup routine called from setup_arch()
10183
* 1. setup swapper's mm @init_mm
@@ -140,8 +122,11 @@ void __init setup_arch_memory(void)
140122
memblock_reserve(low_mem_start, __pa(_end) - low_mem_start);
141123

142124
#ifdef CONFIG_BLK_DEV_INITRD
143-
if (initrd_start)
144-
memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
125+
if (phys_initrd_size) {
126+
memblock_reserve(phys_initrd_start, phys_initrd_size);
127+
initrd_start = (unsigned long)__va(phys_initrd_start);
128+
initrd_end = initrd_start + phys_initrd_size;
129+
}
145130
#endif
146131

147132
early_init_fdt_reserve_self();

arch/arm/mm/init.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,6 @@ unsigned long __init __clear_cr(unsigned long mask)
5151
#endif
5252

5353
#ifdef CONFIG_BLK_DEV_INITRD
54-
static int __init early_initrd(char *p)
55-
{
56-
phys_addr_t start;
57-
unsigned long size;
58-
char *endp;
59-
60-
start = memparse(p, &endp);
61-
if (*endp == ',') {
62-
size = memparse(endp + 1, NULL);
63-
64-
phys_initrd_start = start;
65-
phys_initrd_size = size;
66-
}
67-
return 0;
68-
}
69-
early_param("initrd", early_initrd);
70-
7154
static int __init parse_tag_initrd(const struct tag *tag)
7255
{
7356
pr_warn("ATAG_INITRD is deprecated; "

arch/arm64/mm/init.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@
6161
s64 memstart_addr __ro_after_init = -1;
6262
phys_addr_t arm64_dma_phys_limit __ro_after_init;
6363

64-
#ifdef CONFIG_BLK_DEV_INITRD
65-
static int __init early_initrd(char *p)
66-
{
67-
unsigned long start, size;
68-
char *endp;
69-
70-
start = memparse(p, &endp);
71-
if (*endp == ',') {
72-
size = memparse(endp + 1, NULL);
73-
74-
phys_initrd_start = start;
75-
phys_initrd_size = size;
76-
}
77-
return 0;
78-
}
79-
early_param("initrd", early_initrd);
80-
#endif
81-
8264
#ifdef CONFIG_KEXEC_CORE
8365
/*
8466
* reserve_crashkernel() - reserves memory for crash kernel

arch/unicore32/mm/init.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,6 @@
3030

3131
#include "mm.h"
3232

33-
#ifdef CONFIG_BLK_DEV_INITRD
34-
static int __init early_initrd(char *p)
35-
{
36-
unsigned long start, size;
37-
char *endp;
38-
39-
start = memparse(p, &endp);
40-
if (*endp == ',') {
41-
size = memparse(endp + 1, NULL);
42-
43-
phys_initrd_start = start;
44-
phys_initrd_size = size;
45-
}
46-
return 0;
47-
}
48-
early_param("initrd", early_initrd);
49-
#endif
50-
5133
/*
5234
* This keeps memory configuration data used by a couple memory
5335
* initialization functions, as well as show_mem() for the skipping

init/do_mounts_initrd.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ static int __init no_initrd(char *str)
2727

2828
__setup("noinitrd", no_initrd);
2929

30+
static int __init early_initrd(char *p)
31+
{
32+
phys_addr_t start;
33+
unsigned long size;
34+
char *endp;
35+
36+
start = memparse(p, &endp);
37+
if (*endp == ',') {
38+
size = memparse(endp + 1, NULL);
39+
40+
phys_initrd_start = start;
41+
phys_initrd_size = size;
42+
}
43+
return 0;
44+
}
45+
early_param("initrd", early_initrd);
46+
3047
static int init_linuxrc(struct subprocess_info *info, struct cred *new)
3148
{
3249
ksys_unshare(CLONE_FS | CLONE_FILES);

0 commit comments

Comments
 (0)