Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a61aef7

Browse files
committed
Merge tag 'for-linus-20130628' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-mn10300
Pull two MN10300 fixes from David Howells: "The first fixes a problem with passing arrays rather than pointers to get_user() where __typeof__ then wants to declare and initialise an array variable which gcc doesn't like. The second fixes a problem whereby putting mem=xxx into the kernel command line causes init=xxx to get an incorrect value." * tag 'for-linus-20130628' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-mn10300: mn10300: Use early_param() to parse "mem=" parameter mn10300: Allow to pass array name to get_user()
2 parents a75930c + e3f12a5 commit a61aef7

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

arch/mn10300/include/asm/uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct __large_struct { unsigned long buf[100]; };
161161

162162
#define __get_user_check(x, ptr, size) \
163163
({ \
164-
const __typeof__(ptr) __guc_ptr = (ptr); \
164+
const __typeof__(*(ptr))* __guc_ptr = (ptr); \
165165
int _e; \
166166
if (likely(__access_ok((unsigned long) __guc_ptr, (size)))) \
167167
_e = __get_user_nocheck((x), __guc_ptr, (size)); \

arch/mn10300/kernel/setup.c

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct mn10300_cpuinfo boot_cpu_data;
3838
/* For PCI or other memory-mapped resources */
3939
unsigned long pci_mem_start = 0x18000000;
4040

41+
static char __initdata cmd_line[COMMAND_LINE_SIZE];
4142
char redboot_command_line[COMMAND_LINE_SIZE] =
4243
"console=ttyS0,115200 root=/dev/mtdblock3 rw";
4344

@@ -74,45 +75,19 @@ static const char *const mn10300_cputypes[] = {
7475
};
7576

7677
/*
77-
*
78+
* Pick out the memory size. We look for mem=size,
79+
* where size is "size[KkMm]"
7880
*/
79-
static void __init parse_mem_cmdline(char **cmdline_p)
81+
static int __init early_mem(char *p)
8082
{
81-
char *from, *to, c;
82-
83-
/* save unparsed command line copy for /proc/cmdline */
84-
strcpy(boot_command_line, redboot_command_line);
85-
86-
/* see if there's an explicit memory size option */
87-
from = redboot_command_line;
88-
to = redboot_command_line;
89-
c = ' ';
90-
91-
for (;;) {
92-
if (c == ' ' && !memcmp(from, "mem=", 4)) {
93-
if (to != redboot_command_line)
94-
to--;
95-
memory_size = memparse(from + 4, &from);
96-
}
97-
98-
c = *(from++);
99-
if (!c)
100-
break;
101-
102-
*(to++) = c;
103-
}
104-
105-
*to = '\0';
106-
*cmdline_p = redboot_command_line;
83+
memory_size = memparse(p, &p);
10784

10885
if (memory_size == 0)
10986
panic("Memory size not known\n");
11087

111-
memory_end = (unsigned long) CONFIG_KERNEL_RAM_BASE_ADDRESS +
112-
memory_size;
113-
if (memory_end > phys_memory_end)
114-
memory_end = phys_memory_end;
88+
return 0;
11589
}
90+
early_param("mem", early_mem);
11691

11792
/*
11893
* architecture specific setup
@@ -125,7 +100,20 @@ void __init setup_arch(char **cmdline_p)
125100
cpu_init();
126101
unit_setup();
127102
smp_init_cpus();
128-
parse_mem_cmdline(cmdline_p);
103+
104+
/* save unparsed command line copy for /proc/cmdline */
105+
strlcpy(boot_command_line, redboot_command_line, COMMAND_LINE_SIZE);
106+
107+
/* populate cmd_line too for later use, preserving boot_command_line */
108+
strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
109+
*cmdline_p = cmd_line;
110+
111+
parse_early_param();
112+
113+
memory_end = (unsigned long) CONFIG_KERNEL_RAM_BASE_ADDRESS +
114+
memory_size;
115+
if (memory_end > phys_memory_end)
116+
memory_end = phys_memory_end;
129117

130118
init_mm.start_code = (unsigned long)&_text;
131119
init_mm.end_code = (unsigned long) &_etext;

0 commit comments

Comments
 (0)