Skip to contentSkip to conversation

arm64: use for_each_node_by_type() macro

PATCH Superseded Wei Yongjun 4 participants 7 messages Oct 30, 2013 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: use for_each_node_by_type() macro

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +2 -2
index aa0c9e7..37a4977 100644
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn,  "cpu") {
 		u64 hwid;
 		const __be32 *prop;
 
#1 lore raw

PATCH 1/1 arm64: use for_each_node_by_type() macro

Quoted 14 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +0 -0
index aa0c9e7..37a4977 100644

arch/arm64/kernel/cpu_ops.c int __init cpu_read_ops(struct device_node *dn, int cpu) · line 84

Quoted 9 lines
arch/arm64/kernel/cpu_ops.c +2 -2
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn,  "cpu") {
                                  ^

Extra space here.

Quoted 10 lines
arch/arm64/kernel/cpu_ops.c +0 -0
 		u64 hwid;
 		const __be32 *prop;
 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw

PATCH v2 1/1 arm64: use for_each_node_by_type() macro

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
v1 -> v2: remove extra space

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +2 -2
index aa0c9e7..37a4977 100644
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn, "cpu") {
 		u64 hwid;
 		const __be32 *prop;
 
#4 lore raw

PATCH v2 1/1 arm64: use for_each_node_by_type() macro

In reply to Wei Yongjun
Quoted 18 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
v1 -> v2: remove extra space

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +0 -0
index aa0c9e7..37a4977 100644
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)

arch/arm64/kernel/cpu_ops.c int __init cpu_read_ops(struct device_node *dn, int cpu) · line 87

Quoted 10 lines
arch/arm64/kernel/cpu_ops.c +2 -2
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn, "cpu") {
 		u64 hwid;
 		const __be32 *prop;
 

In fact this function can be simplified by making use of OF helper directly, something like below snippet. But it requires [1] for correct functionality.

Regards,
Sudeep

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-October/206401.html

-->8

arch/arm64/kernel/cpu_ops.c +5 -17
index de78d22..f297a18 100644
@@ -73,22 +73,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-       struct device_node *dn = NULL;
-       u64 mpidr = cpu_logical_map(0);
-
-       while ((dn = of_find_node_by_type(dn, "cpu"))) {
-               u64 hwid;
-               const __be32 *prop;
-
-               prop = of_get_property(dn, "reg", NULL);
-               if (!prop)
-                       continue;
-
-               hwid = of_read_number(prop, of_n_addr_cells(dn));
-               if (hwid == mpidr) {
-                       cpu_read_ops(dn, 0);
-                       of_node_put(dn);
-                       return;
-               }
+       struct device_node *dn = of_get_cpu_node(0, NULL);
+       if (!dn) {
+               pr_err("failed to find device node for boot cpu\n");
+               return;
        }
+       cpu_read_ops(dn, 0);
 }
maintainer
#5 lore raw

PATCH v2 1/1 arm64: use for_each_node_by_type() macro

Quoted 24 lines · Sudeep KarkadaNagesha
Quoted 23 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
v1 -> v2: remove extra space

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +1 -1
index aa0c9e7..37a4977 100644
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
Quoted 8 lines

arch/arm64/kernel/cpu_ops.c int __init cpu_read_ops(struct device_node *dn, int cpu) · line 87

Quoted 5 lines
arch/arm64/kernel/cpu_ops.c +1 -1
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn, "cpu") {
 		u64 hwid;
 		const __be32 *prop;
 

In fact this function can be simplified by making use of OF helper directly, something like below snippet. But it requires [1] for correct functionality.

Thanks. Could you please send a properly formatted patch on top of [1]?

Signature · 1 line
Catalin
#6 lore raw

PATCH v2 1/1 arm64: use for_each_node_by_type() macro

Quoted 34 lines · Catalin Marinas
Quoted 24 lines · Sudeep KarkadaNagesha
Quoted 23 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Use for_each_node_by_type() macro instead of open coding it.

---
v1 -> v2: remove extra space

---
 arch/arm64/kernel/cpu_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/cpu_ops.c +1 -1
index aa0c9e7..37a4977 100644
@@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu)
 
 void __init cpu_read_bootcpu_ops(void)
 {
-	struct device_node *dn = NULL;
+	struct device_node *dn;
 	u64 mpidr = cpu_logical_map(0);
 
Quoted 8 lines

arch/arm64/kernel/cpu_ops.c int __init cpu_read_ops(struct device_node *dn, int cpu) · line 87

Quoted 5 lines
arch/arm64/kernel/cpu_ops.c +1 -1
-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_node_by_type(dn, "cpu") {
 		u64 hwid;
 		const __be32 *prop;
 

In fact this function can be simplified by making use of OF helper directly, something like below snippet. But it requires [1] for correct functionality.

Quoted 1 line

Thanks. Could you please send a properly formatted patch on top of [1]?

Yes it's done [2]

Regards,
Sudeep

[2] http://www.spinics.net/lists/arm-kernel/msg283243.html