[PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM

mem= command line option was being ignored in arch/powerpc if we were not
a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The initial
command line extraction and parsing needed to be moved earlier in the boot
process and have code to actual parse mem= and do something about it.

Also, fixed a compile warning in the file.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Kumar Gala and committed by
Linus Torvalds
329dda08 4853a615

+38 -16
+38 -16
arch/powerpc/kernel/prom.c
··· 816 816 { 817 817 unsigned long start, mem, size; 818 818 struct device_node **allnextp = &allnodes; 819 - char *p = NULL; 820 - int l = 0; 821 819 822 820 DBG(" -> unflatten_device_tree()\n"); 823 821 ··· 854 856 of_chosen = of_find_node_by_path("/chosen"); 855 857 if (of_chosen == NULL) 856 858 of_chosen = of_find_node_by_path("/chosen@0"); 857 - 858 - /* Retreive command line */ 859 - if (of_chosen != NULL) { 860 - p = (char *)get_property(of_chosen, "bootargs", &l); 861 - if (p != NULL && l > 0) 862 - strlcpy(cmd_line, p, min(l, COMMAND_LINE_SIZE)); 863 - } 864 - #ifdef CONFIG_CMDLINE 865 - if (l == 0 || (l == 1 && (*p) == 0)) 866 - strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 867 - #endif /* CONFIG_CMDLINE */ 868 - 869 - DBG("Command line is: %s\n", cmd_line); 870 859 871 860 DBG(" <- unflatten_device_tree()\n"); 872 861 } ··· 925 940 { 926 941 u32 *prop; 927 942 unsigned long *lprop; 943 + unsigned long l; 944 + char *p; 928 945 929 946 DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname); 930 947 ··· 990 1003 if (lprop) 991 1004 crashk_res.end = crashk_res.start + *lprop - 1; 992 1005 #endif 1006 + 1007 + /* Retreive command line */ 1008 + p = of_get_flat_dt_prop(node, "bootargs", &l); 1009 + if (p != NULL && l > 0) 1010 + strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); 1011 + 1012 + #ifdef CONFIG_CMDLINE 1013 + if (l == 0 || (l == 1 && (*p) == 0)) 1014 + strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 1015 + #endif /* CONFIG_CMDLINE */ 1016 + 1017 + DBG("Command line is: %s\n", cmd_line); 1018 + 1019 + if (strstr(cmd_line, "mem=")) { 1020 + char *p, *q; 1021 + unsigned long maxmem = 0; 1022 + 1023 + for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) { 1024 + q = p + 4; 1025 + if (p > cmd_line && p[-1] != ' ') 1026 + continue; 1027 + maxmem = simple_strtoul(q, &q, 0); 1028 + if (*q == 'k' || *q == 'K') { 1029 + maxmem <<= 10; 1030 + ++q; 1031 + } else if (*q == 'm' || *q == 'M') { 1032 + maxmem <<= 20; 1033 + ++q; 1034 + } else if (*q == 'g' || *q == 'G') { 1035 + maxmem <<= 30; 1036 + ++q; 1037 + } 1038 + } 1039 + memory_limit = maxmem; 1040 + } 993 1041 994 1042 /* break now */ 995 1043 return 1; ··· 1146 1124 size_32 = *(reserve_map_32++); 1147 1125 if (size_32 == 0) 1148 1126 break; 1149 - DBG("reserving: %lx -> %lx\n", base_32, size_32); 1127 + DBG("reserving: %x -> %x\n", base_32, size_32); 1150 1128 lmb_reserve(base_32, size_32); 1151 1129 } 1152 1130 return;