aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/prom_init.c')
-rw-r--r--arch/powerpc/kernel/prom_init.c248
1 files changed, 189 insertions, 59 deletions
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index f33ff4163a51..523bb99d7676 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -154,10 +154,8 @@ static struct prom_t __prombss prom;
154 154
155static unsigned long __prombss prom_entry; 155static unsigned long __prombss prom_entry;
156 156
157#define PROM_SCRATCH_SIZE 256
158
159static char __prombss of_stdout_device[256]; 157static char __prombss of_stdout_device[256];
160static char __prombss prom_scratch[PROM_SCRATCH_SIZE]; 158static char __prombss prom_scratch[256];
161 159
162static unsigned long __prombss dt_header_start; 160static unsigned long __prombss dt_header_start;
163static unsigned long __prombss dt_struct_start, dt_struct_end; 161static unsigned long __prombss dt_struct_start, dt_struct_end;
@@ -224,6 +222,135 @@ static bool __prombss rtas_has_query_cpu_stopped;
224#define PHANDLE_VALID(p) ((p) != 0 && (p) != PROM_ERROR) 222#define PHANDLE_VALID(p) ((p) != 0 && (p) != PROM_ERROR)
225#define IHANDLE_VALID(i) ((i) != 0 && (i) != PROM_ERROR) 223#define IHANDLE_VALID(i) ((i) != 0 && (i) != PROM_ERROR)
226 224
225/* Copied from lib/string.c and lib/kstrtox.c */
226
227static int __init prom_strcmp(const char *cs, const char *ct)
228{
229 unsigned char c1, c2;
230
231 while (1) {
232 c1 = *cs++;
233 c2 = *ct++;
234 if (c1 != c2)
235 return c1 < c2 ? -1 : 1;
236 if (!c1)
237 break;
238 }
239 return 0;
240}
241
242static char __init *prom_strcpy(char *dest, const char *src)
243{
244 char *tmp = dest;
245
246 while ((*dest++ = *src++) != '\0')
247 /* nothing */;
248 return tmp;
249}
250
251static int __init prom_strncmp(const char *cs, const char *ct, size_t count)
252{
253 unsigned char c1, c2;
254
255 while (count) {
256 c1 = *cs++;
257 c2 = *ct++;
258 if (c1 != c2)
259 return c1 < c2 ? -1 : 1;
260 if (!c1)
261 break;
262 count--;
263 }
264 return 0;
265}
266
267static size_t __init prom_strlen(const char *s)
268{
269 const char *sc;
270
271 for (sc = s; *sc != '\0'; ++sc)
272 /* nothing */;
273 return sc - s;
274}
275
276static int __init prom_memcmp(const void *cs, const void *ct, size_t count)
277{
278 const unsigned char *su1, *su2;
279 int res = 0;
280
281 for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
282 if ((res = *su1 - *su2) != 0)
283 break;
284 return res;
285}
286
287static char __init *prom_strstr(const char *s1, const char *s2)
288{
289 size_t l1, l2;
290
291 l2 = prom_strlen(s2);
292 if (!l2)
293 return (char *)s1;
294 l1 = prom_strlen(s1);
295 while (l1 >= l2) {
296 l1--;
297 if (!prom_memcmp(s1, s2, l2))
298 return (char *)s1;
299 s1++;
300 }
301 return NULL;
302}
303
304static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)
305{
306 size_t ret = prom_strlen(src);
307
308 if (size) {
309 size_t len = (ret >= size) ? size - 1 : ret;
310 memcpy(dest, src, len);
311 dest[len] = '\0';
312 }
313 return ret;
314}
315
316#ifdef CONFIG_PPC_PSERIES
317static int __init prom_strtobool(const char *s, bool *res)
318{
319 if (!s)
320 return -EINVAL;
321
322 switch (s[0]) {
323 case 'y':
324 case 'Y':
325 case '1':
326 *res = true;
327 return 0;
328 case 'n':
329 case 'N':
330 case '0':
331 *res = false;
332 return 0;
333 case 'o':
334 case 'O':
335 switch (s[1]) {
336 case 'n':
337 case 'N':
338 *res = true;
339 return 0;
340 case 'f':
341 case 'F':
342 *res = false;
343 return 0;
344 default:
345 break;
346 }
347 default:
348 break;
349 }
350
351 return -EINVAL;
352}
353#endif
227 354
228/* This is the one and *ONLY* place where we actually call open 355/* This is the one and *ONLY* place where we actually call open
229 * firmware. 356 * firmware.
@@ -555,7 +682,7 @@ static int __init prom_setprop(phandle node, const char *nodename,
555 add_string(&p, tohex((u32)(unsigned long) value)); 682 add_string(&p, tohex((u32)(unsigned long) value));
556 add_string(&p, tohex(valuelen)); 683 add_string(&p, tohex(valuelen));
557 add_string(&p, tohex(ADDR(pname))); 684 add_string(&p, tohex(ADDR(pname)));
558 add_string(&p, tohex(strlen(pname))); 685 add_string(&p, tohex(prom_strlen(pname)));
559 add_string(&p, "property"); 686 add_string(&p, "property");
560 *p = 0; 687 *p = 0;
561 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd); 688 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd);
@@ -631,33 +758,30 @@ static void __init early_cmdline_parse(void)
631 const char *opt; 758 const char *opt;
632 759
633 char *p; 760 char *p;
634 int l __maybe_unused = 0; 761 int l = 0;
635 762
636 prom_cmd_line[0] = 0; 763 prom_cmd_line[0] = 0;
637 p = prom_cmd_line; 764 p = prom_cmd_line;
638 if ((long)prom.chosen > 0) 765 if ((long)prom.chosen > 0)
639 l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1); 766 l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
640#ifdef CONFIG_CMDLINE 767 if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && (l <= 0 || p[0] == '\0')) /* dbl check */
641 if (l <= 0 || p[0] == '\0') /* dbl check */ 768 prom_strlcpy(prom_cmd_line, CONFIG_CMDLINE, sizeof(prom_cmd_line));
642 strlcpy(prom_cmd_line,
643 CONFIG_CMDLINE, sizeof(prom_cmd_line));
644#endif /* CONFIG_CMDLINE */
645 prom_printf("command line: %s\n", prom_cmd_line); 769 prom_printf("command line: %s\n", prom_cmd_line);
646 770
647#ifdef CONFIG_PPC64 771#ifdef CONFIG_PPC64
648 opt = strstr(prom_cmd_line, "iommu="); 772 opt = prom_strstr(prom_cmd_line, "iommu=");
649 if (opt) { 773 if (opt) {
650 prom_printf("iommu opt is: %s\n", opt); 774 prom_printf("iommu opt is: %s\n", opt);
651 opt += 6; 775 opt += 6;
652 while (*opt && *opt == ' ') 776 while (*opt && *opt == ' ')
653 opt++; 777 opt++;
654 if (!strncmp(opt, "off", 3)) 778 if (!prom_strncmp(opt, "off", 3))
655 prom_iommu_off = 1; 779 prom_iommu_off = 1;
656 else if (!strncmp(opt, "force", 5)) 780 else if (!prom_strncmp(opt, "force", 5))
657 prom_iommu_force_on = 1; 781 prom_iommu_force_on = 1;
658 } 782 }
659#endif 783#endif
660 opt = strstr(prom_cmd_line, "mem="); 784 opt = prom_strstr(prom_cmd_line, "mem=");
661 if (opt) { 785 if (opt) {
662 opt += 4; 786 opt += 4;
663 prom_memory_limit = prom_memparse(opt, (const char **)&opt); 787 prom_memory_limit = prom_memparse(opt, (const char **)&opt);
@@ -669,13 +793,13 @@ static void __init early_cmdline_parse(void)
669 793
670#ifdef CONFIG_PPC_PSERIES 794#ifdef CONFIG_PPC_PSERIES
671 prom_radix_disable = !IS_ENABLED(CONFIG_PPC_RADIX_MMU_DEFAULT); 795 prom_radix_disable = !IS_ENABLED(CONFIG_PPC_RADIX_MMU_DEFAULT);
672 opt = strstr(prom_cmd_line, "disable_radix"); 796 opt = prom_strstr(prom_cmd_line, "disable_radix");
673 if (opt) { 797 if (opt) {
674 opt += 13; 798 opt += 13;
675 if (*opt && *opt == '=') { 799 if (*opt && *opt == '=') {
676 bool val; 800 bool val;
677 801
678 if (kstrtobool(++opt, &val)) 802 if (prom_strtobool(++opt, &val))
679 prom_radix_disable = false; 803 prom_radix_disable = false;
680 else 804 else
681 prom_radix_disable = val; 805 prom_radix_disable = val;
@@ -1028,7 +1152,7 @@ static int __init prom_count_smt_threads(void)
1028 type[0] = 0; 1152 type[0] = 0;
1029 prom_getprop(node, "device_type", type, sizeof(type)); 1153 prom_getprop(node, "device_type", type, sizeof(type));
1030 1154
1031 if (strcmp(type, "cpu")) 1155 if (prom_strcmp(type, "cpu"))
1032 continue; 1156 continue;
1033 /* 1157 /*
1034 * There is an entry for each smt thread, each entry being 1158 * There is an entry for each smt thread, each entry being
@@ -1138,8 +1262,14 @@ static void __init prom_check_platform_support(void)
1138 int prop_len = prom_getproplen(prom.chosen, 1262 int prop_len = prom_getproplen(prom.chosen,
1139 "ibm,arch-vec-5-platform-support"); 1263 "ibm,arch-vec-5-platform-support");
1140 1264
1141 /* First copy the architecture vec template */ 1265 /*
1142 ibm_architecture_vec = ibm_architecture_vec_template; 1266 * First copy the architecture vec template
1267 *
1268 * use memcpy() instead of *vec = *vec_template so that GCC replaces it
1269 * by __memcpy() when KASAN is active
1270 */
1271 memcpy(&ibm_architecture_vec, &ibm_architecture_vec_template,
1272 sizeof(ibm_architecture_vec));
1143 1273
1144 if (prop_len > 1) { 1274 if (prop_len > 1) {
1145 int i; 1275 int i;
@@ -1475,7 +1605,7 @@ static void __init prom_init_mem(void)
1475 */ 1605 */
1476 prom_getprop(node, "name", type, sizeof(type)); 1606 prom_getprop(node, "name", type, sizeof(type));
1477 } 1607 }
1478 if (strcmp(type, "memory")) 1608 if (prom_strcmp(type, "memory"))
1479 continue; 1609 continue;
1480 1610
1481 plen = prom_getprop(node, "reg", regbuf, sizeof(regbuf)); 1611 plen = prom_getprop(node, "reg", regbuf, sizeof(regbuf));
@@ -1487,8 +1617,8 @@ static void __init prom_init_mem(void)
1487 endp = p + (plen / sizeof(cell_t)); 1617 endp = p + (plen / sizeof(cell_t));
1488 1618
1489#ifdef DEBUG_PROM 1619#ifdef DEBUG_PROM
1490 memset(path, 0, PROM_SCRATCH_SIZE); 1620 memset(path, 0, sizeof(prom_scratch));
1491 call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1); 1621 call_prom("package-to-path", 3, 1, node, path, sizeof(prom_scratch) - 1);
1492 prom_debug(" node %s :\n", path); 1622 prom_debug(" node %s :\n", path);
1493#endif /* DEBUG_PROM */ 1623#endif /* DEBUG_PROM */
1494 1624
@@ -1756,19 +1886,19 @@ static void __init prom_initialize_tce_table(void)
1756 prom_getprop(node, "device_type", type, sizeof(type)); 1886 prom_getprop(node, "device_type", type, sizeof(type));
1757 prom_getprop(node, "model", model, sizeof(model)); 1887 prom_getprop(node, "model", model, sizeof(model));
1758 1888
1759 if ((type[0] == 0) || (strstr(type, "pci") == NULL)) 1889 if ((type[0] == 0) || (prom_strstr(type, "pci") == NULL))
1760 continue; 1890 continue;
1761 1891
1762 /* Keep the old logic intact to avoid regression. */ 1892 /* Keep the old logic intact to avoid regression. */
1763 if (compatible[0] != 0) { 1893 if (compatible[0] != 0) {
1764 if ((strstr(compatible, "python") == NULL) && 1894 if ((prom_strstr(compatible, "python") == NULL) &&
1765 (strstr(compatible, "Speedwagon") == NULL) && 1895 (prom_strstr(compatible, "Speedwagon") == NULL) &&
1766 (strstr(compatible, "Winnipeg") == NULL)) 1896 (prom_strstr(compatible, "Winnipeg") == NULL))
1767 continue; 1897 continue;
1768 } else if (model[0] != 0) { 1898 } else if (model[0] != 0) {
1769 if ((strstr(model, "ython") == NULL) && 1899 if ((prom_strstr(model, "ython") == NULL) &&
1770 (strstr(model, "peedwagon") == NULL) && 1900 (prom_strstr(model, "peedwagon") == NULL) &&
1771 (strstr(model, "innipeg") == NULL)) 1901 (prom_strstr(model, "innipeg") == NULL))
1772 continue; 1902 continue;
1773 } 1903 }
1774 1904
@@ -1796,10 +1926,10 @@ static void __init prom_initialize_tce_table(void)
1796 local_alloc_bottom = base; 1926 local_alloc_bottom = base;
1797 1927
1798 /* It seems OF doesn't null-terminate the path :-( */ 1928 /* It seems OF doesn't null-terminate the path :-( */
1799 memset(path, 0, PROM_SCRATCH_SIZE); 1929 memset(path, 0, sizeof(prom_scratch));
1800 /* Call OF to setup the TCE hardware */ 1930 /* Call OF to setup the TCE hardware */
1801 if (call_prom("package-to-path", 3, 1, node, 1931 if (call_prom("package-to-path", 3, 1, node,
1802 path, PROM_SCRATCH_SIZE-1) == PROM_ERROR) { 1932 path, sizeof(prom_scratch) - 1) == PROM_ERROR) {
1803 prom_printf("package-to-path failed\n"); 1933 prom_printf("package-to-path failed\n");
1804 } 1934 }
1805 1935
@@ -1917,12 +2047,12 @@ static void __init prom_hold_cpus(void)
1917 2047
1918 type[0] = 0; 2048 type[0] = 0;
1919 prom_getprop(node, "device_type", type, sizeof(type)); 2049 prom_getprop(node, "device_type", type, sizeof(type));
1920 if (strcmp(type, "cpu") != 0) 2050 if (prom_strcmp(type, "cpu") != 0)
1921 continue; 2051 continue;
1922 2052
1923 /* Skip non-configured cpus. */ 2053 /* Skip non-configured cpus. */
1924 if (prom_getprop(node, "status", type, sizeof(type)) > 0) 2054 if (prom_getprop(node, "status", type, sizeof(type)) > 0)
1925 if (strcmp(type, "okay") != 0) 2055 if (prom_strcmp(type, "okay") != 0)
1926 continue; 2056 continue;
1927 2057
1928 reg = cpu_to_be32(-1); /* make sparse happy */ 2058 reg = cpu_to_be32(-1); /* make sparse happy */
@@ -1998,9 +2128,9 @@ static void __init prom_find_mmu(void)
1998 return; 2128 return;
1999 version[sizeof(version) - 1] = 0; 2129 version[sizeof(version) - 1] = 0;
2000 /* XXX might need to add other versions here */ 2130 /* XXX might need to add other versions here */
2001 if (strcmp(version, "Open Firmware, 1.0.5") == 0) 2131 if (prom_strcmp(version, "Open Firmware, 1.0.5") == 0)
2002 of_workarounds = OF_WA_CLAIM; 2132 of_workarounds = OF_WA_CLAIM;
2003 else if (strncmp(version, "FirmWorks,3.", 12) == 0) { 2133 else if (prom_strncmp(version, "FirmWorks,3.", 12) == 0) {
2004 of_workarounds = OF_WA_CLAIM | OF_WA_LONGTRAIL; 2134 of_workarounds = OF_WA_CLAIM | OF_WA_LONGTRAIL;
2005 call_prom("interpret", 1, 1, "dev /memory 0 to allow-reclaim"); 2135 call_prom("interpret", 1, 1, "dev /memory 0 to allow-reclaim");
2006 } else 2136 } else
@@ -2033,7 +2163,7 @@ static void __init prom_init_stdout(void)
2033 call_prom("instance-to-path", 3, 1, prom.stdout, path, 255); 2163 call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
2034 prom_printf("OF stdout device is: %s\n", of_stdout_device); 2164 prom_printf("OF stdout device is: %s\n", of_stdout_device);
2035 prom_setprop(prom.chosen, "/chosen", "linux,stdout-path", 2165 prom_setprop(prom.chosen, "/chosen", "linux,stdout-path",
2036 path, strlen(path) + 1); 2166 path, prom_strlen(path) + 1);
2037 2167
2038 /* instance-to-package fails on PA-Semi */ 2168 /* instance-to-package fails on PA-Semi */
2039 stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout); 2169 stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
@@ -2043,7 +2173,7 @@ static void __init prom_init_stdout(void)
2043 /* If it's a display, note it */ 2173 /* If it's a display, note it */
2044 memset(type, 0, sizeof(type)); 2174 memset(type, 0, sizeof(type));
2045 prom_getprop(stdout_node, "device_type", type, sizeof(type)); 2175 prom_getprop(stdout_node, "device_type", type, sizeof(type));
2046 if (strcmp(type, "display") == 0) 2176 if (prom_strcmp(type, "display") == 0)
2047 prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0); 2177 prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
2048 } 2178 }
2049} 2179}
@@ -2064,19 +2194,19 @@ static int __init prom_find_machine_type(void)
2064 compat[len] = 0; 2194 compat[len] = 0;
2065 while (i < len) { 2195 while (i < len) {
2066 char *p = &compat[i]; 2196 char *p = &compat[i];
2067 int sl = strlen(p); 2197 int sl = prom_strlen(p);
2068 if (sl == 0) 2198 if (sl == 0)
2069 break; 2199 break;
2070 if (strstr(p, "Power Macintosh") || 2200 if (prom_strstr(p, "Power Macintosh") ||
2071 strstr(p, "MacRISC")) 2201 prom_strstr(p, "MacRISC"))
2072 return PLATFORM_POWERMAC; 2202 return PLATFORM_POWERMAC;
2073#ifdef CONFIG_PPC64 2203#ifdef CONFIG_PPC64
2074 /* We must make sure we don't detect the IBM Cell 2204 /* We must make sure we don't detect the IBM Cell
2075 * blades as pSeries due to some firmware issues, 2205 * blades as pSeries due to some firmware issues,
2076 * so we do it here. 2206 * so we do it here.
2077 */ 2207 */
2078 if (strstr(p, "IBM,CBEA") || 2208 if (prom_strstr(p, "IBM,CBEA") ||
2079 strstr(p, "IBM,CPBW-1.0")) 2209 prom_strstr(p, "IBM,CPBW-1.0"))
2080 return PLATFORM_GENERIC; 2210 return PLATFORM_GENERIC;
2081#endif /* CONFIG_PPC64 */ 2211#endif /* CONFIG_PPC64 */
2082 i += sl + 1; 2212 i += sl + 1;
@@ -2093,7 +2223,7 @@ static int __init prom_find_machine_type(void)
2093 compat, sizeof(compat)-1); 2223 compat, sizeof(compat)-1);
2094 if (len <= 0) 2224 if (len <= 0)
2095 return PLATFORM_GENERIC; 2225 return PLATFORM_GENERIC;
2096 if (strcmp(compat, "chrp")) 2226 if (prom_strcmp(compat, "chrp"))
2097 return PLATFORM_GENERIC; 2227 return PLATFORM_GENERIC;
2098 2228
2099 /* Default to pSeries. We need to know if we are running LPAR */ 2229 /* Default to pSeries. We need to know if we are running LPAR */
@@ -2155,19 +2285,19 @@ static void __init prom_check_displays(void)
2155 for (node = 0; prom_next_node(&node); ) { 2285 for (node = 0; prom_next_node(&node); ) {
2156 memset(type, 0, sizeof(type)); 2286 memset(type, 0, sizeof(type));
2157 prom_getprop(node, "device_type", type, sizeof(type)); 2287 prom_getprop(node, "device_type", type, sizeof(type));
2158 if (strcmp(type, "display") != 0) 2288 if (prom_strcmp(type, "display") != 0)
2159 continue; 2289 continue;
2160 2290
2161 /* It seems OF doesn't null-terminate the path :-( */ 2291 /* It seems OF doesn't null-terminate the path :-( */
2162 path = prom_scratch; 2292 path = prom_scratch;
2163 memset(path, 0, PROM_SCRATCH_SIZE); 2293 memset(path, 0, sizeof(prom_scratch));
2164 2294
2165 /* 2295 /*
2166 * leave some room at the end of the path for appending extra 2296 * leave some room at the end of the path for appending extra
2167 * arguments 2297 * arguments
2168 */ 2298 */
2169 if (call_prom("package-to-path", 3, 1, node, path, 2299 if (call_prom("package-to-path", 3, 1, node, path,
2170 PROM_SCRATCH_SIZE-10) == PROM_ERROR) 2300 sizeof(prom_scratch) - 10) == PROM_ERROR)
2171 continue; 2301 continue;
2172 prom_printf("found display : %s, opening... ", path); 2302 prom_printf("found display : %s, opening... ", path);
2173 2303
@@ -2259,9 +2389,9 @@ static unsigned long __init dt_find_string(char *str)
2259 s = os = (char *)dt_string_start; 2389 s = os = (char *)dt_string_start;
2260 s += 4; 2390 s += 4;
2261 while (s < (char *)dt_string_end) { 2391 while (s < (char *)dt_string_end) {
2262 if (strcmp(s, str) == 0) 2392 if (prom_strcmp(s, str) == 0)
2263 return s - os; 2393 return s - os;
2264 s += strlen(s) + 1; 2394 s += prom_strlen(s) + 1;
2265 } 2395 }
2266 return 0; 2396 return 0;
2267} 2397}
@@ -2294,7 +2424,7 @@ static void __init scan_dt_build_strings(phandle node,
2294 } 2424 }
2295 2425
2296 /* skip "name" */ 2426 /* skip "name" */
2297 if (strcmp(namep, "name") == 0) { 2427 if (prom_strcmp(namep, "name") == 0) {
2298 *mem_start = (unsigned long)namep; 2428 *mem_start = (unsigned long)namep;
2299 prev_name = "name"; 2429 prev_name = "name";
2300 continue; 2430 continue;
@@ -2306,7 +2436,7 @@ static void __init scan_dt_build_strings(phandle node,
2306 namep = sstart + soff; 2436 namep = sstart + soff;
2307 } else { 2437 } else {
2308 /* Trim off some if we can */ 2438 /* Trim off some if we can */
2309 *mem_start = (unsigned long)namep + strlen(namep) + 1; 2439 *mem_start = (unsigned long)namep + prom_strlen(namep) + 1;
2310 dt_string_end = *mem_start; 2440 dt_string_end = *mem_start;
2311 } 2441 }
2312 prev_name = namep; 2442 prev_name = namep;
@@ -2363,8 +2493,8 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2363 2493
2364 /* get it again for debugging */ 2494 /* get it again for debugging */
2365 path = prom_scratch; 2495 path = prom_scratch;
2366 memset(path, 0, PROM_SCRATCH_SIZE); 2496 memset(path, 0, sizeof(prom_scratch));
2367 call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1); 2497 call_prom("package-to-path", 3, 1, node, path, sizeof(prom_scratch) - 1);
2368 2498
2369 /* get and store all properties */ 2499 /* get and store all properties */
2370 prev_name = ""; 2500 prev_name = "";
@@ -2375,7 +2505,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2375 break; 2505 break;
2376 2506
2377 /* skip "name" */ 2507 /* skip "name" */
2378 if (strcmp(pname, "name") == 0) { 2508 if (prom_strcmp(pname, "name") == 0) {
2379 prev_name = "name"; 2509 prev_name = "name";
2380 continue; 2510 continue;
2381 } 2511 }
@@ -2406,7 +2536,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2406 call_prom("getprop", 4, 1, node, pname, valp, l); 2536 call_prom("getprop", 4, 1, node, pname, valp, l);
2407 *mem_start = _ALIGN(*mem_start, 4); 2537 *mem_start = _ALIGN(*mem_start, 4);
2408 2538
2409 if (!strcmp(pname, "phandle")) 2539 if (!prom_strcmp(pname, "phandle"))
2410 has_phandle = 1; 2540 has_phandle = 1;
2411 } 2541 }
2412 2542
@@ -2476,8 +2606,8 @@ static void __init flatten_device_tree(void)
2476 2606
2477 /* Add "phandle" in there, we'll need it */ 2607 /* Add "phandle" in there, we'll need it */
2478 namep = make_room(&mem_start, &mem_end, 16, 1); 2608 namep = make_room(&mem_start, &mem_end, 16, 1);
2479 strcpy(namep, "phandle"); 2609 prom_strcpy(namep, "phandle");
2480 mem_start = (unsigned long)namep + strlen(namep) + 1; 2610 mem_start = (unsigned long)namep + prom_strlen(namep) + 1;
2481 2611
2482 /* Build string array */ 2612 /* Build string array */
2483 prom_printf("Building dt strings...\n"); 2613 prom_printf("Building dt strings...\n");
@@ -2799,7 +2929,7 @@ static void __init fixup_device_tree_efika(void)
2799 rv = prom_getprop(node, "model", prop, sizeof(prop)); 2929 rv = prom_getprop(node, "model", prop, sizeof(prop));
2800 if (rv == PROM_ERROR) 2930 if (rv == PROM_ERROR)
2801 return; 2931 return;
2802 if (strcmp(prop, "EFIKA5K2")) 2932 if (prom_strcmp(prop, "EFIKA5K2"))
2803 return; 2933 return;
2804 2934
2805 prom_printf("Applying EFIKA device tree fixups\n"); 2935 prom_printf("Applying EFIKA device tree fixups\n");
@@ -2807,13 +2937,13 @@ static void __init fixup_device_tree_efika(void)
2807 /* Claiming to be 'chrp' is death */ 2937 /* Claiming to be 'chrp' is death */
2808 node = call_prom("finddevice", 1, 1, ADDR("/")); 2938 node = call_prom("finddevice", 1, 1, ADDR("/"));
2809 rv = prom_getprop(node, "device_type", prop, sizeof(prop)); 2939 rv = prom_getprop(node, "device_type", prop, sizeof(prop));
2810 if (rv != PROM_ERROR && (strcmp(prop, "chrp") == 0)) 2940 if (rv != PROM_ERROR && (prom_strcmp(prop, "chrp") == 0))
2811 prom_setprop(node, "/", "device_type", "efika", sizeof("efika")); 2941 prom_setprop(node, "/", "device_type", "efika", sizeof("efika"));
2812 2942
2813 /* CODEGEN,description is exposed in /proc/cpuinfo so 2943 /* CODEGEN,description is exposed in /proc/cpuinfo so
2814 fix that too */ 2944 fix that too */
2815 rv = prom_getprop(node, "CODEGEN,description", prop, sizeof(prop)); 2945 rv = prom_getprop(node, "CODEGEN,description", prop, sizeof(prop));
2816 if (rv != PROM_ERROR && (strstr(prop, "CHRP"))) 2946 if (rv != PROM_ERROR && (prom_strstr(prop, "CHRP")))
2817 prom_setprop(node, "/", "CODEGEN,description", 2947 prom_setprop(node, "/", "CODEGEN,description",
2818 "Efika 5200B PowerPC System", 2948 "Efika 5200B PowerPC System",
2819 sizeof("Efika 5200B PowerPC System")); 2949 sizeof("Efika 5200B PowerPC System"));