aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/lparcfg.c6
-rw-r--r--arch/powerpc/kernel/pci_32.c17
-rw-r--r--arch/powerpc/kernel/prom.c14
-rw-r--r--arch/powerpc/kernel/rtas.c3
-rw-r--r--arch/powerpc/kernel/sysfs.c3
-rw-r--r--arch/powerpc/platforms/chrp/pci.c7
-rw-r--r--arch/powerpc/platforms/chrp/setup.c9
-rw-r--r--arch/powerpc/platforms/powermac/feature.c34
8 files changed, 53 insertions, 40 deletions
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index b8dc1eeb0169..fc1f7a949b2b 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -321,7 +321,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
321 struct device_node *rtas_node; 321 struct device_node *rtas_node;
322 const int *lrdrp = NULL; 322 const int *lrdrp = NULL;
323 323
324 rtas_node = find_path_device("/rtas"); 324 rtas_node = of_find_node_by_path("/rtas");
325 if (rtas_node) 325 if (rtas_node)
326 lrdrp = of_get_property(rtas_node, "ibm,lrdr-capacity", NULL); 326 lrdrp = of_get_property(rtas_node, "ibm,lrdr-capacity", NULL);
327 327
@@ -330,6 +330,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
330 } else { 330 } else {
331 partition_potential_processors = *(lrdrp + 4); 331 partition_potential_processors = *(lrdrp + 4);
332 } 332 }
333 of_node_put(rtas_node);
333 334
334 partition_active_processors = lparcfg_count_active_processors(); 335 partition_active_processors = lparcfg_count_active_processors();
335 336
@@ -537,7 +538,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
537 538
538 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS); 539 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
539 540
540 rootdn = find_path_device("/"); 541 rootdn = of_find_node_by_path("/");
541 if (rootdn) { 542 if (rootdn) {
542 tmp = of_get_property(rootdn, "model", NULL); 543 tmp = of_get_property(rootdn, "model", NULL);
543 if (tmp) { 544 if (tmp) {
@@ -557,6 +558,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
557 NULL); 558 NULL);
558 if (lp_index_ptr) 559 if (lp_index_ptr)
559 lp_index = *lp_index_ptr; 560 lp_index = *lp_index_ptr;
561 of_node_put(rootdn);
560 } 562 }
561 seq_printf(m, "serial_number=%s\n", system_id); 563 seq_printf(m, "serial_number=%s\n", system_id);
562 seq_printf(m, "system_type=%s\n", model); 564 seq_printf(m, "system_type=%s\n", model);
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index ae04f9418363..5b05a09a6bdf 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -669,6 +669,7 @@ pcibios_make_OF_bus_map(void)
669 int i; 669 int i;
670 struct pci_controller* hose; 670 struct pci_controller* hose;
671 struct property *map_prop; 671 struct property *map_prop;
672 struct device_node *dn;
672 673
673 pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL); 674 pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL);
674 if (!pci_to_OF_bus_map) { 675 if (!pci_to_OF_bus_map) {
@@ -690,12 +691,13 @@ pcibios_make_OF_bus_map(void)
690 continue; 691 continue;
691 make_one_node_map(node, hose->first_busno); 692 make_one_node_map(node, hose->first_busno);
692 } 693 }
693 map_prop = of_find_property(find_path_device("/"), 694 dn = of_find_node_by_path("/");
694 "pci-OF-bus-map", NULL); 695 map_prop = of_find_property(dn, "pci-OF-bus-map", NULL);
695 if (map_prop) { 696 if (map_prop) {
696 BUG_ON(pci_bus_count > map_prop->length); 697 BUG_ON(pci_bus_count > map_prop->length);
697 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count); 698 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
698 } 699 }
700 of_node_put(dn);
699#ifdef DEBUG 701#ifdef DEBUG
700 printk("PCI->OF bus map:\n"); 702 printk("PCI->OF bus map:\n");
701 for (i=0; i<pci_bus_count; i++) { 703 for (i=0; i<pci_bus_count; i++) {
@@ -1006,14 +1008,19 @@ void __init
1006pci_create_OF_bus_map(void) 1008pci_create_OF_bus_map(void)
1007{ 1009{
1008 struct property* of_prop; 1010 struct property* of_prop;
1009 1011 struct device_node *dn;
1012
1010 of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256); 1013 of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256);
1011 if (of_prop && find_path_device("/")) { 1014 if (!of_prop)
1015 return;
1016 dn = of_find_node_by_path("/");
1017 if (dn) {
1012 memset(of_prop, -1, sizeof(struct property) + 256); 1018 memset(of_prop, -1, sizeof(struct property) + 256);
1013 of_prop->name = "pci-OF-bus-map"; 1019 of_prop->name = "pci-OF-bus-map";
1014 of_prop->length = 256; 1020 of_prop->length = 256;
1015 of_prop->value = &of_prop[1]; 1021 of_prop->value = &of_prop[1];
1016 prom_add_property(find_path_device("/"), of_prop); 1022 prom_add_property(dn, of_prop);
1023 of_node_put(dn);
1017 } 1024 }
1018} 1025}
1019 1026
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 911ec77a42d2..17c41fefecf2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1153,20 +1153,6 @@ int machine_is_compatible(const char *compat)
1153} 1153}
1154EXPORT_SYMBOL(machine_is_compatible); 1154EXPORT_SYMBOL(machine_is_compatible);
1155 1155
1156/**
1157 * Find the device_node with a given full_name.
1158 */
1159struct device_node *find_path_device(const char *path)
1160{
1161 struct device_node *np;
1162
1163 for (np = allnodes; np != 0; np = np->allnext)
1164 if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
1165 return np;
1166 return NULL;
1167}
1168EXPORT_SYMBOL(find_path_device);
1169
1170/******* 1156/*******
1171 * 1157 *
1172 * New implementation of the OF "find" APIs, return a refcounted 1158 * New implementation of the OF "find" APIs, return a refcounted
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 702fecc93204..214780798289 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -192,7 +192,7 @@ void rtas_progress(char *s, unsigned short hex)
192 192
193 if (display_width == 0) { 193 if (display_width == 0) {
194 display_width = 0x10; 194 display_width = 0x10;
195 if ((root = find_path_device("/rtas"))) { 195 if ((root = of_find_node_by_path("/rtas"))) {
196 if ((p = of_get_property(root, 196 if ((p = of_get_property(root,
197 "ibm,display-line-length", NULL))) 197 "ibm,display-line-length", NULL)))
198 display_width = *p; 198 display_width = *p;
@@ -204,6 +204,7 @@ void rtas_progress(char *s, unsigned short hex)
204 display_lines = *p; 204 display_lines = *p;
205 row_width = of_get_property(root, 205 row_width = of_get_property(root,
206 "ibm,display-truncation-length", NULL); 206 "ibm,display-truncation-length", NULL);
207 of_node_put(root);
207 } 208 }
208 display_character = rtas_token("display-character"); 209 display_character = rtas_token("display-character");
209 set_indicator = rtas_token("set-indicator"); 210 set_indicator = rtas_token("set-indicator");
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 6fc27e771b5a..933e214c33e8 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -66,7 +66,7 @@ static int __init smt_setup(void)
66 if (!cpu_has_feature(CPU_FTR_SMT)) 66 if (!cpu_has_feature(CPU_FTR_SMT))
67 return -ENODEV; 67 return -ENODEV;
68 68
69 options = find_path_device("/options"); 69 options = of_find_node_by_path("/options");
70 if (!options) 70 if (!options)
71 return -ENODEV; 71 return -ENODEV;
72 72
@@ -76,6 +76,7 @@ static int __init smt_setup(void)
76 per_cpu(smt_snooze_delay, cpu) = *val; 76 per_cpu(smt_snooze_delay, cpu) = *val;
77 } 77 }
78 78
79 of_node_put(options);
79 return 0; 80 return 0;
80} 81}
81__initcall(smt_setup); 82__initcall(smt_setup);
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index b23e39796a0b..de776e3889e3 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -185,10 +185,9 @@ setup_python(struct pci_controller *hose, struct device_node *dev)
185/* Marvell Discovery II based Pegasos 2 */ 185/* Marvell Discovery II based Pegasos 2 */
186static void __init setup_peg2(struct pci_controller *hose, struct device_node *dev) 186static void __init setup_peg2(struct pci_controller *hose, struct device_node *dev)
187{ 187{
188 struct device_node *root = find_path_device("/"); 188 struct device_node *root = of_find_node_by_path("/");
189 struct device_node *rtas; 189 struct device_node *rtas;
190 190
191 of_node_get(root);
192 rtas = of_find_node_by_name (root, "rtas"); 191 rtas = of_find_node_by_name (root, "rtas");
193 if (rtas) { 192 if (rtas) {
194 hose->ops = &rtas_pci_ops; 193 hose->ops = &rtas_pci_ops;
@@ -198,6 +197,7 @@ static void __init setup_peg2(struct pci_controller *hose, struct device_node *d
198 " your firmware\n"); 197 " your firmware\n");
199 } 198 }
200 pci_assign_all_buses = 1; 199 pci_assign_all_buses = 1;
200 /* keep the reference to the root node */
201} 201}
202 202
203void __init 203void __init
@@ -210,7 +210,7 @@ chrp_find_bridges(void)
210 const unsigned int *dma; 210 const unsigned int *dma;
211 const char *model, *machine; 211 const char *model, *machine;
212 int is_longtrail = 0, is_mot = 0, is_pegasos = 0; 212 int is_longtrail = 0, is_mot = 0, is_pegasos = 0;
213 struct device_node *root = find_path_device("/"); 213 struct device_node *root = of_find_node_by_path("/");
214 struct resource r; 214 struct resource r;
215 /* 215 /*
216 * The PCI host bridge nodes on some machines don't have 216 * The PCI host bridge nodes on some machines don't have
@@ -309,6 +309,7 @@ chrp_find_bridges(void)
309 printk("pci_dram_offset = %lx\n", pci_dram_offset); 309 printk("pci_dram_offset = %lx\n", pci_dram_offset);
310 } 310 }
311 } 311 }
312 of_node_put(root);
312} 313}
313 314
314/* SL82C105 IDE Control/Status Register */ 315/* SL82C105 IDE Control/Status Register */
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 05d1bc0c8918..e46c4d4a5804 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -110,7 +110,7 @@ void chrp_show_cpuinfo(struct seq_file *m)
110 struct device_node *root; 110 struct device_node *root;
111 const char *model = ""; 111 const char *model = "";
112 112
113 root = find_path_device("/"); 113 root = of_find_node_by_path("/");
114 if (root) 114 if (root)
115 model = of_get_property(root, "model", NULL); 115 model = of_get_property(root, "model", NULL);
116 seq_printf(m, "machine\t\t: CHRP %s\n", model); 116 seq_printf(m, "machine\t\t: CHRP %s\n", model);
@@ -160,6 +160,7 @@ void chrp_show_cpuinfo(struct seq_file *m)
160 gg2_cachetypes[(t>>2) & 3], 160 gg2_cachetypes[(t>>2) & 3],
161 gg2_cachemodes[t & 3]); 161 gg2_cachemodes[t & 3]);
162 } 162 }
163 of_node_put(root);
163} 164}
164 165
165/* 166/*
@@ -204,7 +205,7 @@ static void __init sio_init(void)
204{ 205{
205 struct device_node *root; 206 struct device_node *root;
206 207
207 if ((root = find_path_device("/")) && 208 if ((root = of_find_node_by_path("/")) &&
208 !strncmp(of_get_property(root, "model", NULL), 209 !strncmp(of_get_property(root, "model", NULL),
209 "IBM,LongTrail", 13)) { 210 "IBM,LongTrail", 13)) {
210 /* logical device 0 (KBC/Keyboard) */ 211 /* logical device 0 (KBC/Keyboard) */
@@ -212,6 +213,7 @@ static void __init sio_init(void)
212 /* select logical device 1 (KBC/Mouse) */ 213 /* select logical device 1 (KBC/Mouse) */
213 sio_fixup_irq("mouse", 1, 12, 2); 214 sio_fixup_irq("mouse", 1, 12, 2);
214 } 215 }
216 of_node_put(root);
215} 217}
216 218
217 219
@@ -250,7 +252,7 @@ static void briq_restart(char *cmd)
250 252
251void __init chrp_setup_arch(void) 253void __init chrp_setup_arch(void)
252{ 254{
253 struct device_node *root = find_path_device ("/"); 255 struct device_node *root = of_find_node_by_path("/");
254 const char *machine = NULL; 256 const char *machine = NULL;
255 257
256 /* init to some ~sane value until calibrate_delay() runs */ 258 /* init to some ~sane value until calibrate_delay() runs */
@@ -273,6 +275,7 @@ void __init chrp_setup_arch(void)
273 /* Let's assume it is an IBM chrp if all else fails */ 275 /* Let's assume it is an IBM chrp if all else fails */
274 _chrp_type = _CHRP_IBM; 276 _chrp_type = _CHRP_IBM;
275 } 277 }
278 of_node_put(root);
276 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]); 279 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]);
277 280
278 rtas_initialize(); 281 rtas_initialize();
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 103fcc4c5605..44f85507db3c 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1044,6 +1044,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1044 unsigned long flags; 1044 unsigned long flags;
1045 struct macio_chip *macio; 1045 struct macio_chip *macio;
1046 struct device_node *np; 1046 struct device_node *np;
1047 struct device_node *cpus;
1047 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, 1048 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
1048 KL_GPIO_RESET_CPU1, 1049 KL_GPIO_RESET_CPU1,
1049 KL_GPIO_RESET_CPU2, 1050 KL_GPIO_RESET_CPU2,
@@ -1053,10 +1054,10 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1053 if (macio->type != macio_keylargo) 1054 if (macio->type != macio_keylargo)
1054 return -ENODEV; 1055 return -ENODEV;
1055 1056
1056 np = find_path_device("/cpus"); 1057 cpus = of_find_node_by_path("/cpus");
1057 if (np == NULL) 1058 if (cpus == NULL)
1058 return -ENODEV; 1059 return -ENODEV;
1059 for (np = np->child; np != NULL; np = np->sibling) { 1060 for (np = cpus->child; np != NULL; np = np->sibling) {
1060 const u32 *num = of_get_property(np, "reg", NULL); 1061 const u32 *num = of_get_property(np, "reg", NULL);
1061 const u32 *rst = of_get_property(np, "soft-reset", NULL); 1062 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1062 if (num == NULL || rst == NULL) 1063 if (num == NULL || rst == NULL)
@@ -1066,6 +1067,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1066 break; 1067 break;
1067 } 1068 }
1068 } 1069 }
1070 of_node_put(cpus);
1069 if (np == NULL || reset_io == 0) 1071 if (np == NULL || reset_io == 0)
1070 reset_io = dflt_reset_lines[param]; 1072 reset_io = dflt_reset_lines[param];
1071 1073
@@ -1497,15 +1499,16 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1497 unsigned long flags; 1499 unsigned long flags;
1498 struct macio_chip *macio; 1500 struct macio_chip *macio;
1499 struct device_node *np; 1501 struct device_node *np;
1502 struct device_node *cpus;
1500 1503
1501 macio = &macio_chips[0]; 1504 macio = &macio_chips[0];
1502 if (macio->type != macio_keylargo2 && macio->type != macio_shasta) 1505 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1503 return -ENODEV; 1506 return -ENODEV;
1504 1507
1505 np = find_path_device("/cpus"); 1508 cpus = of_find_node_by_path("/cpus");
1506 if (np == NULL) 1509 if (cpus == NULL)
1507 return -ENODEV; 1510 return -ENODEV;
1508 for (np = np->child; np != NULL; np = np->sibling) { 1511 for (np = cpus->child; np != NULL; np = np->sibling) {
1509 const u32 *num = of_get_property(np, "reg", NULL); 1512 const u32 *num = of_get_property(np, "reg", NULL);
1510 const u32 *rst = of_get_property(np, "soft-reset", NULL); 1513 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1511 if (num == NULL || rst == NULL) 1514 if (num == NULL || rst == NULL)
@@ -1515,6 +1518,7 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1515 break; 1518 break;
1516 } 1519 }
1517 } 1520 }
1521 of_node_put(cpus);
1518 if (np == NULL || reset_io == 0) 1522 if (np == NULL || reset_io == 0)
1519 return -ENODEV; 1523 return -ENODEV;
1520 1524
@@ -2499,18 +2503,26 @@ found:
2499 * that all Apple OF revs did it properly, I do it the paranoid way. 2503 * that all Apple OF revs did it properly, I do it the paranoid way.
2500 */ 2504 */
2501 while (uninorth_base && uninorth_rev > 3) { 2505 while (uninorth_base && uninorth_rev > 3) {
2502 struct device_node *np = find_path_device("/cpus"); 2506 struct device_node *cpus = of_find_node_by_path("/cpus");
2503 if (!np || !np->child) { 2507 struct device_node *np;
2508
2509 if (!cpus || !cpus->child) {
2504 printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); 2510 printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
2511 of_node_put(cpus);
2505 break; 2512 break;
2506 } 2513 }
2507 np = np->child; 2514 np = cpus->child;
2508 /* Nap mode not supported on SMP */ 2515 /* Nap mode not supported on SMP */
2509 if (np->sibling) 2516 if (np->sibling) {
2517 of_node_put(cpus);
2510 break; 2518 break;
2519 }
2511 /* Nap mode not supported if flush-on-lock property is present */ 2520 /* Nap mode not supported if flush-on-lock property is present */
2512 if (of_get_property(np, "flush-on-lock", NULL)) 2521 if (of_get_property(np, "flush-on-lock", NULL)) {
2522 of_node_put(cpus);
2513 break; 2523 break;
2524 }
2525 of_node_put(cpus);
2514 powersave_nap = 1; 2526 powersave_nap = 1;
2515 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); 2527 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
2516 break; 2528 break;