All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 11/21] powerpc: use for_each_of_cpu_node iterator
Date: Wed,  5 Sep 2018 14:37:28 -0500	[thread overview]
Message-ID: <20180905193738.19325-12-robh@kernel.org> (raw)
In-Reply-To: <20180905193738.19325-1-robh@kernel.org>

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>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/powerpc/platforms/powermac/feature.c | 51 ++++++++---------------
 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)
 	unsigned long flags;
 	struct macio_chip *macio;
 	struct device_node *np;
-	struct device_node *cpus;
 	const int dflt_reset_lines[] = {	KL_GPIO_RESET_CPU0,
 						KL_GPIO_RESET_CPU1,
 						KL_GPIO_RESET_CPU2,
@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
 	if (macio->type != macio_keylargo)
 		return -ENODEV;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL)
-		return -ENODEV;
-	for (np = cpus->child; np != NULL; np = np->sibling) {
+	for_each_of_cpu_node(np) {
 		const u32 *num = of_get_property(np, "reg", NULL);
 		const u32 *rst = of_get_property(np, "soft-reset", NULL);
 		if (num == NULL || rst == NULL)
@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
 			break;
 		}
 	}
-	of_node_put(cpus);
 	if (np == NULL || reset_io == 0)
 		reset_io = dflt_reset_lines[param];

@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
 	unsigned long flags;
 	struct macio_chip *macio;
 	struct device_node *np;
-	struct device_node *cpus;

 	macio = &macio_chips[0];
 	if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
 		return -ENODEV;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL)
-		return -ENODEV;
-	for (np = cpus->child; np != NULL; np = np->sibling) {
+	for_each_of_cpu_node(np) {
 		const u32 *num = of_get_property(np, "reg", NULL);
 		const u32 *rst = of_get_property(np, "soft-reset", NULL);
 		if (num == NULL || rst == NULL)
@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
 			break;
 		}
 	}
-	of_node_put(cpus);
 	if (np == NULL || reset_io == 0)
 		return -ENODEV;

@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void)
 	 * 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.
 	 */
-	while (uninorth_base && uninorth_rev > 3) {
-		struct device_node *cpus = of_find_node_by_path("/cpus");
+	if (uninorth_base && uninorth_rev > 3) {
 		struct device_node *np;

-		if (!cpus || !cpus->child) {
-			printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
-			of_node_put(cpus);
-			break;
-		}
-		np = cpus->child;
-		/* Nap mode not supported on SMP */
-		if (np->sibling) {
-			of_node_put(cpus);
-			break;
-		}
-		/* Nap mode not supported if flush-on-lock property is present */
-		if (of_get_property(np, "flush-on-lock", NULL)) {
-			of_node_put(cpus);
-			break;
+		for_each_of_cpu_node(np) {
+			int cpu_count = 1;
+
+			/* Nap mode not supported on SMP */
+			if (of_get_property(np, "flush-on-lock", NULL) ||
+			    (cpu_count > 1)) {
+				powersave_nap = 0;
+				of_node_put(np);
+				break;
+			}
+
+			cpu_count++;
+			powersave_nap = 1;
 		}
-		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
 	 * 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)
 {
 	/* Checks "l2cr-value" property in the registry */
 	if (cpu_has_feature(CPU_FTR_L2CR)) {
-		struct device_node *np = of_find_node_by_name(NULL, "cpus");
-		if (!np)
-			np = of_find_node_by_type(NULL, "cpu");
-		if (np) {
+		struct device_node *np;
+
+		for_each_of_cpu_node(np) {
 			const unsigned int *l2cr =
 				of_get_property(np, "l2cr-value", NULL);
 			if (l2cr) {
@@ -256,6 +255,7 @@ static void __init l2cr_init(void)
 				_set_L2CR(ppc_override_l2cr_value);
 			}
 			of_node_put(np);
+			break;
 		}
 	}

@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void)
 	/* Set loops_per_jiffy to a half-way reasonable value,
 	   for use until calibrate_delay gets called. */
 	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);
 		if (fp != NULL) {
 			if (pvr >= 0x30 && pvr < 0x80)
@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void)
 			else
 				/* 601, 603, etc. */
 				loops_per_jiffy = *fp / (2 * HZ);
+			of_node_put(cpu);
+			break;
 		}
-		of_node_put(cpu);
 	}

 	/* See if newworld or oldworld */
--
2.17.1

  parent reply	other threads:[~2018-09-05 19:37 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
2018-09-05 19:37 ` [OpenRISC] " Rob Herring
2018-09-05 19:37 ` Rob Herring
2018-09-05 19:37 ` Rob Herring
2018-09-05 19:37 ` Rob Herring
2018-09-05 19:37 ` Rob Herring
2018-09-05 19:37 ` Rob Herring
2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
2018-09-06  8:45   ` Geert Uytterhoeven
2018-09-06  8:45     ` Geert Uytterhoeven
2018-10-30 14:18   ` Michael Ellerman
2018-10-30 14:20     ` Michael Ellerman
2018-10-30 15:00       ` Rob Herring
2018-10-30 15:00         ` Rob Herring
2018-11-01 10:52         ` Michael Ellerman
2018-11-01 10:52           ` Michael Ellerman
2018-11-01 15:12           ` Segher Boessenkool
2018-11-01 15:12             ` Segher Boessenkool
2018-11-01 15:57             ` Rob Herring
2018-11-01 15:57               ` Rob Herring
2018-09-05 19:37 ` [PATCH 02/21] of: Support matching cpu nodes with no 'reg' property Rob Herring
2018-09-05 19:37 ` [PATCH 03/21] ARM: use for_each_of_cpu_node iterator Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-05 19:37 ` [PATCH 04/21] ARM: topology: remove unneeded check for /cpus node Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-06  8:52   ` Geert Uytterhoeven
2018-09-06  8:52     ` Geert Uytterhoeven
2018-09-06  8:52     ` Geert Uytterhoeven
2018-09-06  8:56   ` Simon Horman
2018-09-06  8:56     ` Simon Horman
2018-09-05 19:37 ` [PATCH 06/21] arm64: " Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-06 10:04   ` Will Deacon
2018-09-06 10:04     ` Will Deacon
2018-09-05 19:37 ` [PATCH 07/21] c6x: " Rob Herring
2018-09-05 19:37 ` [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node Rob Herring
2018-09-10 14:56   ` Michal Simek
2018-09-10 14:56     ` Michal Simek
2018-09-10 20:49     ` Rob Herring
2018-09-11 12:15       ` Michal Simek
2018-09-11 12:15         ` Michal Simek
2018-09-05 19:37 ` [PATCH 09/21] nios2: " Rob Herring
2018-09-05 19:37 ` [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator Rob Herring
2018-09-05 19:37   ` [OpenRISC] " Rob Herring
2018-09-06  9:12   ` Stafford Horne
2018-09-06  9:12     ` [OpenRISC] " Stafford Horne
2018-09-05 19:37 ` Rob Herring [this message]
2018-09-05 19:37 ` [PATCH 12/21] powerpc: 4xx: get cpu node with of_get_cpu_node Rob Herring
2018-09-05 19:37 ` [PATCH 13/21] powerpc: 8xx: " Rob Herring
2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-10 13:37   ` Christoph Hellwig
2018-09-10 13:37     ` Christoph Hellwig
2018-09-10 13:51     ` Rob Herring
2018-09-10 13:51       ` Rob Herring
2018-09-18 22:53   ` Palmer Dabbelt
2018-09-18 22:53     ` Palmer Dabbelt
2018-09-05 19:37 ` [PATCH 15/21] SH: " Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-05 19:37 ` [PATCH 16/21] x86: DT: " Rob Herring
2018-09-06  8:15   ` Thomas Gleixner
2018-09-05 19:37 ` [PATCH 17/21] clk: mvebu: " Rob Herring
2018-09-06  1:47   ` Stephen Boyd
2018-09-06  1:47     ` Stephen Boyd
2018-09-05 19:37 ` [PATCH 18/21] edac: cpc925: " Rob Herring
2018-09-05 19:37   ` [18/21] " Rob Herring
2018-09-06  8:35   ` [PATCH 18/21] " Borislav Petkov
2018-09-06  8:35     ` [18/21] " Borislav Petkov
2018-09-06 11:12     ` [PATCH 18/21] " Rob Herring
2018-09-06 11:12       ` [18/21] " Rob Herring
2018-09-06 12:20       ` [PATCH 18/21] " Borislav Petkov
2018-09-06 12:20         ` [18/21] " Borislav Petkov
2018-09-05 19:37 ` [PATCH 19/21] iommu: fsl_pamu: " Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-05 19:37 ` [PATCH 20/21] of: " Rob Herring
2018-10-31 12:46   ` NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator) Michael Ellerman
2018-10-31 14:25     ` Rob Herring
2018-11-01 10:55       ` Michael Ellerman
2018-11-01 10:55         ` Michael Ellerman
2018-09-05 19:37 ` [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-05 19:37   ` Rob Herring
2018-09-11  3:34   ` Timur Tabi
2018-09-11  3:34     ` Timur Tabi
2018-09-11  3:34     ` Timur Tabi
     [not found] ` <20180905193738.19325-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-09-07 12:54   ` [PATCH 00/21] DT cpu node iterator Michal Simek
2018-09-07 12:54     ` [OpenRISC] " Michal Simek
2018-09-07 12:54     ` Michal Simek
2018-09-07 13:58     ` Rob Herring
2018-09-07 13:58       ` [OpenRISC] " Rob Herring
2018-09-07 13:58       ` Rob Herring
2018-09-07 13:58       ` Rob Herring
2018-09-07 13:58       ` Rob Herring
2018-09-07 13:58       ` Rob Herring
2018-09-07 13:58       ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905193738.19325-12-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.