diff mbox series

[18/21] edac: cpc925: use for_each_of_cpu_node iterator

Message ID 20180905193738.19325-19-robh@kernel.org
State New
Headers show
Series [01/21] of: Add cpu node iterator for_each_of_cpu_node() | expand

Commit Message

Rob Herring Sept. 5, 2018, 7:37 p.m. UTC
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: Borislav Petkov <bp@alien8.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-edac@vger.kernel.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.

 drivers/edac/cpc925_edac.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

--
2.17.1

Comments

Borislav Petkov Sept. 6, 2018, 8:35 a.m. UTC | #1
On Wed, Sep 05, 2018 at 02:37:35PM -0500, Rob Herring wrote:
> 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: Borislav Petkov <bp@alien8.de>

> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>

> Cc: linux-edac@vger.kernel.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.


Completely unknown territory for me so I'd trust your judgement. Staring
at 1/21, the conversion looks ok except the removal of those prints that
a cpu nodes are not present - I wonder if they even meant anything or
were just there during driver development...

>  drivers/edac/cpc925_edac.c | 20 ++------------------

>  1 file changed, 2 insertions(+), 18 deletions(-)

> 

> diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c

> index 2c98e020df05..3c0881ac9880 100644

> --- a/drivers/edac/cpc925_edac.c

> +++ b/drivers/edac/cpc925_edac.c

> @@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)

>  /******************** CPU err device********************************/

>  static u32 cpc925_cpu_mask_disabled(void)

>  {

> -	struct device_node *cpus;

> -	struct device_node *cpunode = NULL;

> +	struct device_node *cpunode;

>  	static u32 mask = 0;

> 

>  	/* use cached value if available */

> @@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void)

> 

>  	mask = APIMASK_ADI0 | APIMASK_ADI1;

> 

> -	cpus = of_find_node_by_path("/cpus");

> -	if (cpus == NULL) {

> -		cpc925_printk(KERN_DEBUG, "No /cpus node !\n");


This thing...

> -		return 0;

> -	}

> -

> -	while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {

> +	for_each_of_cpu_node(cpunode) {

>  		const u32 *reg = of_get_property(cpunode, "reg", NULL);

> -

> -		if (strcmp(cpunode->type, "cpu")) {

> -			cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);


... and this thing.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
Rob Herring Sept. 6, 2018, 11:12 a.m. UTC | #2
On Thu, Sep 6, 2018 at 3:35 AM Borislav Petkov <bp@alien8.de> wrote:
>

> On Wed, Sep 05, 2018 at 02:37:35PM -0500, Rob Herring wrote:

> > 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: Borislav Petkov <bp@alien8.de>

> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>

> > Cc: linux-edac@vger.kernel.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.

>

> Completely unknown territory for me so I'd trust your judgement. Staring

> at 1/21, the conversion looks ok except the removal of those prints that

> a cpu nodes are not present - I wonder if they even meant anything or

> were just there during driver development...


I should have noted this. It's not the kernel's job to validate the DT
and certainly not some driver's job to validate cpu nodes. It's bad
enough that some random driver is parsing cpu nodes. If they are
missing or are crap, you should get warnings or messages well before
this point.

Rob
Borislav Petkov Sept. 6, 2018, 12:20 p.m. UTC | #3
On Thu, Sep 06, 2018 at 06:12:51AM -0500, Rob Herring wrote:
> I should have noted this. It's not the kernel's job to validate the DT

> and certainly not some driver's job to validate cpu nodes. It's bad

> enough that some random driver is parsing cpu nodes. If they are

> missing or are crap, you should get warnings or messages well before

> this point.


That is useful info for the commit message, I'd say.

In any case:

Acked-by: Borislav Petkov <bp@suse.de>


-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
diff mbox series

Patch

diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index 2c98e020df05..3c0881ac9880 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -593,8 +593,7 @@  static void cpc925_mc_check(struct mem_ctl_info *mci)
 /******************** CPU err device********************************/
 static u32 cpc925_cpu_mask_disabled(void)
 {
-	struct device_node *cpus;
-	struct device_node *cpunode = NULL;
+	struct device_node *cpunode;
 	static u32 mask = 0;

 	/* use cached value if available */
@@ -603,20 +602,8 @@  static u32 cpc925_cpu_mask_disabled(void)

 	mask = APIMASK_ADI0 | APIMASK_ADI1;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL) {
-		cpc925_printk(KERN_DEBUG, "No /cpus node !\n");
-		return 0;
-	}
-
-	while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {
+	for_each_of_cpu_node(cpunode) {
 		const u32 *reg = of_get_property(cpunode, "reg", NULL);
-
-		if (strcmp(cpunode->type, "cpu")) {
-			cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);
-			continue;
-		}
-
 		if (reg == NULL || *reg > 2) {
 			cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode);
 			continue;
@@ -633,9 +620,6 @@  static u32 cpc925_cpu_mask_disabled(void)
 				"Assuming PI id is equal to CPU MPIC id!\n");
 	}

-	of_node_put(cpunode);
-	of_node_put(cpus);
-
 	return mask;
 }