From: Johan Hovold <johan@kernel.org>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
Andreas Schwab <schwab@suse.de>,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
Atish Patra <atish.patra@wdc.com>,
Anup Patel <anup@brainfault.org>,
linux-riscv@lists.infradead.org
Subject: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Date: Fri, 18 Jan 2019 15:03:08 +0100 [thread overview]
Message-ID: <20190118140308.9599-6-johan@kernel.org> (raw)
In-Reply-To: <20190118140308.9599-1-johan@kernel.org>
Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
instead of open coding. Note that this will allow matching also on the
node name instead of the (for FDT) deprecated device_type property.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
arch/riscv/kernel/cpufeature.c | 5 +++--
arch/riscv/kernel/smpboot.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 4891fd62b95e..e7a4701f0256 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -28,7 +28,7 @@ bool has_fpu __read_mostly;
void riscv_fill_hwcap(void)
{
- struct device_node *node = NULL;
+ struct device_node *node;
const char *isa;
size_t i;
static unsigned long isa2hwcap[256] = {0};
@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void)
* We don't support running Linux on hertergenous ISA systems. For
* now, we just check the ISA of the first "okay" processor.
*/
- while ((node = of_find_node_by_type(node, "cpu")))
+ for_each_of_cpu_node(node) {
if (riscv_of_processor_hartid(node) >= 0)
break;
+ }
if (!node) {
pr_warn("Unable to find \"cpu\" devicetree entry\n");
return;
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 18cda0e8cf94..6e2813257e03 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
void __init setup_smp(void)
{
- struct device_node *dn = NULL;
+ struct device_node *dn;
int hart;
bool found_boot_cpu = false;
int cpuid = 1;
- while ((dn = of_find_node_by_type(dn, "cpu"))) {
+ for_each_of_cpu_node(dn) {
hart = riscv_of_processor_hartid(dn);
if (hart < 0)
continue;
--
2.20.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Johan Hovold <johan@kernel.org>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
Andreas Schwab <schwab@suse.de>,
Atish Patra <atish.patra@wdc.com>,
Anup Patel <anup@brainfault.org>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator
Date: Fri, 18 Jan 2019 15:03:08 +0100 [thread overview]
Message-ID: <20190118140308.9599-6-johan@kernel.org> (raw)
In-Reply-To: <20190118140308.9599-1-johan@kernel.org>
Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
instead of open coding. Note that this will allow matching also on the
node name instead of the (for FDT) deprecated device_type property.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
arch/riscv/kernel/cpufeature.c | 5 +++--
arch/riscv/kernel/smpboot.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 4891fd62b95e..e7a4701f0256 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -28,7 +28,7 @@ bool has_fpu __read_mostly;
void riscv_fill_hwcap(void)
{
- struct device_node *node = NULL;
+ struct device_node *node;
const char *isa;
size_t i;
static unsigned long isa2hwcap[256] = {0};
@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void)
* We don't support running Linux on hertergenous ISA systems. For
* now, we just check the ISA of the first "okay" processor.
*/
- while ((node = of_find_node_by_type(node, "cpu")))
+ for_each_of_cpu_node(node) {
if (riscv_of_processor_hartid(node) >= 0)
break;
+ }
if (!node) {
pr_warn("Unable to find \"cpu\" devicetree entry\n");
return;
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 18cda0e8cf94..6e2813257e03 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
void __init setup_smp(void)
{
- struct device_node *dn = NULL;
+ struct device_node *dn;
int hart;
bool found_boot_cpu = false;
int cpuid = 1;
- while ((dn = of_find_node_by_type(dn, "cpu"))) {
+ for_each_of_cpu_node(dn) {
hart = riscv_of_processor_hartid(dn);
if (hart < 0)
continue;
--
2.20.1
next prev parent reply other threads:[~2019-01-18 14:04 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-18 14:03 [PATCH 0/5] riscv: minor fixes and cleanups Johan Hovold
2019-01-18 14:03 ` Johan Hovold
2019-01-18 14:03 ` [PATCH 1/5] riscv: add missing newlines to printk messages Johan Hovold
2019-01-18 14:03 ` Johan Hovold
2019-02-12 7:11 ` Christoph Hellwig
2019-02-12 7:11 ` Christoph Hellwig
2019-01-18 14:03 ` [PATCH 2/5] riscv: use pr_info and friends Johan Hovold
2019-01-18 14:03 ` Johan Hovold
2019-01-19 1:39 ` Paul Walmsley
2019-01-19 1:39 ` Paul Walmsley
2019-02-12 7:11 ` Christoph Hellwig
2019-02-12 7:11 ` Christoph Hellwig
2019-01-18 14:03 ` [PATCH 3/5] riscv: fix riscv_of_processor_hartid() comment Johan Hovold
2019-01-18 14:03 ` Johan Hovold
2019-01-19 1:40 ` Paul Walmsley
2019-01-19 1:40 ` Paul Walmsley
2019-02-12 7:12 ` Christoph Hellwig
2019-02-12 7:12 ` Christoph Hellwig
2019-01-18 14:03 ` [PATCH 4/5] riscv: treat cpu devicetree nodes without status as enabled Johan Hovold
2019-01-18 14:03 ` Johan Hovold
2019-01-19 1:43 ` Paul Walmsley
2019-01-19 1:43 ` Paul Walmsley
2019-01-21 8:59 ` Johan Hovold
2019-01-21 8:59 ` Johan Hovold
2019-02-12 7:12 ` Christoph Hellwig
2019-02-12 7:12 ` Christoph Hellwig
2019-01-18 14:03 ` Johan Hovold [this message]
2019-01-18 14:03 ` [PATCH 5/5] riscv: use for_each_of_cpu_node iterator Johan Hovold
2019-02-12 7:13 ` Christoph Hellwig
2019-02-12 7:13 ` Christoph Hellwig
2019-02-12 8:26 ` Johan Hovold
2019-02-12 8:26 ` Johan Hovold
2019-02-12 8:47 ` Atish Patra
2019-02-12 8:47 ` Atish Patra
2019-02-12 8:53 ` Johan Hovold
2019-02-12 8:53 ` Johan Hovold
2019-02-12 9:20 ` Atish Patra
2019-02-12 9:20 ` Atish Patra
2019-02-11 9:34 ` [PATCH 0/5] riscv: minor fixes and cleanups Johan Hovold
2019-02-11 9:34 ` Johan Hovold
2019-02-11 19:59 ` Palmer Dabbelt
2019-02-11 19:59 ` Palmer Dabbelt
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=20190118140308.9599-6-johan@kernel.org \
--to=johan@kernel.org \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@wdc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@sifive.com \
--cc=schwab@suse.de \
/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.