diff options
author | Rob Herring <robh@kernel.org> | 2018-08-27 13:24:09 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-09-28 15:25:58 -0400 |
commit | a94fe366340ac4d19f8bd88850ab681d9022f3ae (patch) | |
tree | 1e311327a0589cd9754398afa7933e2fc5e7c112 | |
parent | 5e5abae858b5d3d060a441cc5da0859cd8cb2c82 (diff) |
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: Rob Herring <robh@kernel.org>
-rw-r--r-- | arch/powerpc/platforms/powermac/feature.c | 51 | ||||
-rw-r--r-- | arch/powerpc/platforms/powermac/setup.c | 15 |
2 files changed, 26 insertions, 40 deletions
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 4eb8cb38fc69..ed2f54b3f173 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c | |||
@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1049 | unsigned long flags; | 1049 | unsigned long flags; |
1050 | struct macio_chip *macio; | 1050 | struct macio_chip *macio; |
1051 | struct device_node *np; | 1051 | struct device_node *np; |
1052 | struct device_node *cpus; | ||
1053 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, | 1052 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, |
1054 | KL_GPIO_RESET_CPU1, | 1053 | KL_GPIO_RESET_CPU1, |
1055 | KL_GPIO_RESET_CPU2, | 1054 | KL_GPIO_RESET_CPU2, |
@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1059 | if (macio->type != macio_keylargo) | 1058 | if (macio->type != macio_keylargo) |
1060 | return -ENODEV; | 1059 | return -ENODEV; |
1061 | 1060 | ||
1062 | cpus = of_find_node_by_path("/cpus"); | 1061 | for_each_of_cpu_node(np) { |
1063 | if (cpus == NULL) | ||
1064 | return -ENODEV; | ||
1065 | for (np = cpus->child; np != NULL; np = np->sibling) { | ||
1066 | const u32 *num = of_get_property(np, "reg", NULL); | 1062 | const u32 *num = of_get_property(np, "reg", NULL); |
1067 | const u32 *rst = of_get_property(np, "soft-reset", NULL); | 1063 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
1068 | if (num == NULL || rst == NULL) | 1064 | if (num == NULL || rst == NULL) |
@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1072 | break; | 1068 | break; |
1073 | } | 1069 | } |
1074 | } | 1070 | } |
1075 | of_node_put(cpus); | ||
1076 | if (np == NULL || reset_io == 0) | 1071 | if (np == NULL || reset_io == 0) |
1077 | reset_io = dflt_reset_lines[param]; | 1072 | reset_io = dflt_reset_lines[param]; |
1078 | 1073 | ||
@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
1504 | unsigned long flags; | 1499 | unsigned long flags; |
1505 | struct macio_chip *macio; | 1500 | struct macio_chip *macio; |
1506 | struct device_node *np; | 1501 | struct device_node *np; |
1507 | struct device_node *cpus; | ||
1508 | 1502 | ||
1509 | macio = &macio_chips[0]; | 1503 | macio = &macio_chips[0]; |
1510 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) | 1504 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) |
1511 | return -ENODEV; | 1505 | return -ENODEV; |
1512 | 1506 | ||
1513 | cpus = of_find_node_by_path("/cpus"); | 1507 | for_each_of_cpu_node(np) { |
1514 | if (cpus == NULL) | ||
1515 | return -ENODEV; | ||
1516 | for (np = cpus->child; np != NULL; np = np->sibling) { | ||
1517 | const u32 *num = of_get_property(np, "reg", NULL); | 1508 | const u32 *num = of_get_property(np, "reg", NULL); |
1518 | const u32 *rst = of_get_property(np, "soft-reset", NULL); | 1509 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
1519 | if (num == NULL || rst == NULL) | 1510 | if (num == NULL || rst == NULL) |
@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
1523 | break; | 1514 | break; |
1524 | } | 1515 | } |
1525 | } | 1516 | } |
1526 | of_node_put(cpus); | ||
1527 | if (np == NULL || reset_io == 0) | 1517 | if (np == NULL || reset_io == 0) |
1528 | return -ENODEV; | 1518 | return -ENODEV; |
1529 | 1519 | ||
@@ -2515,31 +2505,26 @@ found: | |||
2515 | * supposed to be set when not supported, but I'm not very confident | 2505 | * supposed to be set when not supported, but I'm not very confident |
2516 | * that all Apple OF revs did it properly, I do it the paranoid way. | 2506 | * that all Apple OF revs did it properly, I do it the paranoid way. |
2517 | */ | 2507 | */ |
2518 | while (uninorth_base && uninorth_rev > 3) { | 2508 | if (uninorth_base && uninorth_rev > 3) { |
2519 | struct device_node *cpus = of_find_node_by_path("/cpus"); | ||
2520 | struct device_node *np; | 2509 | struct device_node *np; |
2521 | 2510 | ||
2522 | if (!cpus || !cpus->child) { | 2511 | for_each_of_cpu_node(np) { |
2523 | printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); | 2512 | int cpu_count = 1; |
2524 | of_node_put(cpus); | 2513 | |
2525 | break; | 2514 | /* Nap mode not supported on SMP */ |
2526 | } | 2515 | if (of_get_property(np, "flush-on-lock", NULL) || |
2527 | np = cpus->child; | 2516 | (cpu_count > 1)) { |
2528 | /* Nap mode not supported on SMP */ | 2517 | powersave_nap = 0; |
2529 | if (np->sibling) { | 2518 | of_node_put(np); |
2530 | of_node_put(cpus); | 2519 | break; |
2531 | break; | 2520 | } |
2532 | } | 2521 | |
2533 | /* Nap mode not supported if flush-on-lock property is present */ | 2522 | cpu_count++; |
2534 | if (of_get_property(np, "flush-on-lock", NULL)) { | 2523 | powersave_nap = 1; |
2535 | of_node_put(cpus); | ||
2536 | break; | ||
2537 | } | 2524 | } |
2538 | of_node_put(cpus); | ||
2539 | powersave_nap = 1; | ||
2540 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); | ||
2541 | break; | ||
2542 | } | 2525 | } |
2526 | if (powersave_nap) | ||
2527 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); | ||
2543 | 2528 | ||
2544 | /* On CPUs that support it (750FX), lowspeed by default during | 2529 | /* On CPUs that support it (750FX), lowspeed by default during |
2545 | * NAP mode | 2530 | * NAP mode |
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c index 3a529fcdae97..2f00e3daafb0 100644 --- a/arch/powerpc/platforms/powermac/setup.c +++ b/arch/powerpc/platforms/powermac/setup.c | |||
@@ -243,10 +243,9 @@ static void __init l2cr_init(void) | |||
243 | { | 243 | { |
244 | /* Checks "l2cr-value" property in the registry */ | 244 | /* Checks "l2cr-value" property in the registry */ |
245 | if (cpu_has_feature(CPU_FTR_L2CR)) { | 245 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
246 | struct device_node *np = of_find_node_by_name(NULL, "cpus"); | 246 | struct device_node *np; |
247 | if (!np) | 247 | |
248 | np = of_find_node_by_type(NULL, "cpu"); | 248 | for_each_of_cpu_node(np) { |
249 | if (np) { | ||
250 | const unsigned int *l2cr = | 249 | const unsigned int *l2cr = |
251 | of_get_property(np, "l2cr-value", NULL); | 250 | of_get_property(np, "l2cr-value", NULL); |
252 | if (l2cr) { | 251 | if (l2cr) { |
@@ -256,6 +255,7 @@ static void __init l2cr_init(void) | |||
256 | _set_L2CR(ppc_override_l2cr_value); | 255 | _set_L2CR(ppc_override_l2cr_value); |
257 | } | 256 | } |
258 | of_node_put(np); | 257 | of_node_put(np); |
258 | break; | ||
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void) | |||
279 | /* Set loops_per_jiffy to a half-way reasonable value, | 279 | /* Set loops_per_jiffy to a half-way reasonable value, |
280 | for use until calibrate_delay gets called. */ | 280 | for use until calibrate_delay gets called. */ |
281 | loops_per_jiffy = 50000000 / HZ; | 281 | loops_per_jiffy = 50000000 / HZ; |
282 | cpu = of_find_node_by_type(NULL, "cpu"); | 282 | |
283 | if (cpu != NULL) { | 283 | for_each_of_cpu_node(cpu) { |
284 | fp = of_get_property(cpu, "clock-frequency", NULL); | 284 | fp = of_get_property(cpu, "clock-frequency", NULL); |
285 | if (fp != NULL) { | 285 | if (fp != NULL) { |
286 | if (pvr >= 0x30 && pvr < 0x80) | 286 | if (pvr >= 0x30 && pvr < 0x80) |
@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void) | |||
292 | else | 292 | else |
293 | /* 601, 603, etc. */ | 293 | /* 601, 603, etc. */ |
294 | loops_per_jiffy = *fp / (2 * HZ); | 294 | loops_per_jiffy = *fp / (2 * HZ); |
295 | of_node_put(cpu); | ||
296 | break; | ||
295 | } | 297 | } |
296 | of_node_put(cpu); | ||
297 | } | 298 | } |
298 | 299 | ||
299 | /* See if newworld or oldworld */ | 300 | /* See if newworld or oldworld */ |