Commit a94fe366 authored by Rob Herring's avatar Rob Herring

powerpc: use for_each_of_cpu_node iterator

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 5e5abae8
...@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
unsigned long flags; unsigned long flags;
struct macio_chip *macio; struct macio_chip *macio;
struct device_node *np; struct device_node *np;
struct device_node *cpus;
const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
KL_GPIO_RESET_CPU1, KL_GPIO_RESET_CPU1,
KL_GPIO_RESET_CPU2, KL_GPIO_RESET_CPU2,
...@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
if (macio->type != macio_keylargo) if (macio->type != macio_keylargo)
return -ENODEV; return -ENODEV;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (cpus == NULL)
return -ENODEV;
for (np = cpus->child; np != NULL; np = np->sibling) {
const u32 *num = of_get_property(np, "reg", NULL); const u32 *num = of_get_property(np, "reg", NULL);
const u32 *rst = of_get_property(np, "soft-reset", NULL); const u32 *rst = of_get_property(np, "soft-reset", NULL);
if (num == NULL || rst == NULL) if (num == NULL || rst == NULL)
...@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
break; break;
} }
} }
of_node_put(cpus);
if (np == NULL || reset_io == 0) if (np == NULL || reset_io == 0)
reset_io = dflt_reset_lines[param]; reset_io = dflt_reset_lines[param];
...@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) ...@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
unsigned long flags; unsigned long flags;
struct macio_chip *macio; struct macio_chip *macio;
struct device_node *np; struct device_node *np;
struct device_node *cpus;
macio = &macio_chips[0]; macio = &macio_chips[0];
if (macio->type != macio_keylargo2 && macio->type != macio_shasta) if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
return -ENODEV; return -ENODEV;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (cpus == NULL)
return -ENODEV;
for (np = cpus->child; np != NULL; np = np->sibling) {
const u32 *num = of_get_property(np, "reg", NULL); const u32 *num = of_get_property(np, "reg", NULL);
const u32 *rst = of_get_property(np, "soft-reset", NULL); const u32 *rst = of_get_property(np, "soft-reset", NULL);
if (num == NULL || rst == NULL) if (num == NULL || rst == NULL)
...@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) ...@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
break; break;
} }
} }
of_node_put(cpus);
if (np == NULL || reset_io == 0) if (np == NULL || reset_io == 0)
return -ENODEV; return -ENODEV;
...@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void) ...@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void)
* supposed to be set when not supported, but I'm not very confident * supposed to be set when not supported, but I'm not very confident
* that all Apple OF revs did it properly, I do it the paranoid way. * that all Apple OF revs did it properly, I do it the paranoid way.
*/ */
while (uninorth_base && uninorth_rev > 3) { if (uninorth_base && uninorth_rev > 3) {
struct device_node *cpus = of_find_node_by_path("/cpus");
struct device_node *np; struct device_node *np;
if (!cpus || !cpus->child) { for_each_of_cpu_node(np) {
printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); int cpu_count = 1;
of_node_put(cpus);
break; /* Nap mode not supported on SMP */
} if (of_get_property(np, "flush-on-lock", NULL) ||
np = cpus->child; (cpu_count > 1)) {
/* Nap mode not supported on SMP */ powersave_nap = 0;
if (np->sibling) { of_node_put(np);
of_node_put(cpus); break;
break; }
}
/* Nap mode not supported if flush-on-lock property is present */ cpu_count++;
if (of_get_property(np, "flush-on-lock", NULL)) { powersave_nap = 1;
of_node_put(cpus);
break;
} }
of_node_put(cpus);
powersave_nap = 1;
printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
break;
} }
if (powersave_nap)
printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
/* On CPUs that support it (750FX), lowspeed by default during /* On CPUs that support it (750FX), lowspeed by default during
* NAP mode * NAP mode
......
...@@ -243,10 +243,9 @@ static void __init l2cr_init(void) ...@@ -243,10 +243,9 @@ static void __init l2cr_init(void)
{ {
/* Checks "l2cr-value" property in the registry */ /* Checks "l2cr-value" property in the registry */
if (cpu_has_feature(CPU_FTR_L2CR)) { if (cpu_has_feature(CPU_FTR_L2CR)) {
struct device_node *np = of_find_node_by_name(NULL, "cpus"); struct device_node *np;
if (!np)
np = of_find_node_by_type(NULL, "cpu"); for_each_of_cpu_node(np) {
if (np) {
const unsigned int *l2cr = const unsigned int *l2cr =
of_get_property(np, "l2cr-value", NULL); of_get_property(np, "l2cr-value", NULL);
if (l2cr) { if (l2cr) {
...@@ -256,6 +255,7 @@ static void __init l2cr_init(void) ...@@ -256,6 +255,7 @@ static void __init l2cr_init(void)
_set_L2CR(ppc_override_l2cr_value); _set_L2CR(ppc_override_l2cr_value);
} }
of_node_put(np); of_node_put(np);
break;
} }
} }
...@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void) ...@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void)
/* Set loops_per_jiffy to a half-way reasonable value, /* Set loops_per_jiffy to a half-way reasonable value,
for use until calibrate_delay gets called. */ for use until calibrate_delay gets called. */
loops_per_jiffy = 50000000 / HZ; loops_per_jiffy = 50000000 / HZ;
cpu = of_find_node_by_type(NULL, "cpu");
if (cpu != NULL) { for_each_of_cpu_node(cpu) {
fp = of_get_property(cpu, "clock-frequency", NULL); fp = of_get_property(cpu, "clock-frequency", NULL);
if (fp != NULL) { if (fp != NULL) {
if (pvr >= 0x30 && pvr < 0x80) if (pvr >= 0x30 && pvr < 0x80)
...@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void) ...@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void)
else else
/* 601, 603, etc. */ /* 601, 603, etc. */
loops_per_jiffy = *fp / (2 * HZ); loops_per_jiffy = *fp / (2 * HZ);
of_node_put(cpu);
break;
} }
of_node_put(cpu);
} }
/* See if newworld or oldworld */ /* See if newworld or oldworld */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment