diff mbox series

[RFC] powerpc/drmem: use global variable instead of fetching again

Message ID 20200806125200.252403-1-aneesh.kumar@linux.ibm.com
State New
Headers show
Series [RFC] powerpc/drmem: use global variable instead of fetching again | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (3cd2184115b85cc8242fec3d42529cd112962984)
snowpatch_ozlabs/build-ppc64le warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-ppc64be warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-ppc64e warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/build-pmac32 warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 64 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Aneesh Kumar K V Aug. 6, 2020, 12:52 p.m. UTC
use mem_addr_cells/mem_size_cells instead of fetching the values
again from device tree.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 arch/powerpc/mm/drmem.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

Comments

Hari Bathini Aug. 17, 2020, 5:31 p.m. UTC | #1
On 06/08/20 6:22 pm, Aneesh Kumar K.V wrote:
> use mem_addr_cells/mem_size_cells instead of fetching the values
> again from device tree.
> 

Looks good to me.

> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>   arch/powerpc/mm/drmem.c | 24 ++++++------------------
>   1 file changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
> index b2eeea39684c..f533a7b04ab9 100644
> --- a/arch/powerpc/mm/drmem.c
> +++ b/arch/powerpc/mm/drmem.c
> @@ -14,8 +14,6 @@
>   #include <asm/prom.h>
>   #include <asm/drmem.h>
>   
> -static int n_root_addr_cells, n_root_size_cells;
> -
>   static struct drmem_lmb_info __drmem_info;
>   struct drmem_lmb_info *drmem_info = &__drmem_info;
>   
> @@ -196,8 +194,8 @@ static void read_drconf_v1_cell(struct drmem_lmb *lmb,
>   {
>   	const __be32 *p = *prop;
>   
> -	lmb->base_addr = of_read_number(p, n_root_addr_cells);
> -	p += n_root_addr_cells;
> +	lmb->base_addr = of_read_number(p, mem_addr_cells);
> +	p += mem_addr_cells;
>   	lmb->drc_index = of_read_number(p++, 1);
>   
>   	p++; /* skip reserved field */
> @@ -233,8 +231,8 @@ static void read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
>   	const __be32 *p = *prop;
>   
>   	dr_cell->seq_lmbs = of_read_number(p++, 1);
> -	dr_cell->base_addr = of_read_number(p, n_root_addr_cells);
> -	p += n_root_addr_cells;
> +	dr_cell->base_addr = of_read_number(p, mem_addr_cells);
> +	p += mem_addr_cells;
>   	dr_cell->drc_index = of_read_number(p++, 1);
>   	dr_cell->aa_index = of_read_number(p++, 1);
>   	dr_cell->flags = of_read_number(p++, 1);
> @@ -285,10 +283,6 @@ int __init walk_drmem_lmbs_early(unsigned long node, void *data,
>   	if (!prop || len < dt_root_size_cells * sizeof(__be32))
>   		return ret;
>   
> -	/* Get the address & size cells */
> -	n_root_addr_cells = dt_root_addr_cells;
> -	n_root_size_cells = dt_root_size_cells;
> -
>   	drmem_info->lmb_size = dt_mem_next_cell(dt_root_size_cells, &prop);
>   
>   	usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", &len);
> @@ -318,12 +312,12 @@ static int init_drmem_lmb_size(struct device_node *dn)
>   		return 0;
>   
>   	prop = of_get_property(dn, "ibm,lmb-size", &len);
> -	if (!prop || len < n_root_size_cells * sizeof(__be32)) {
> +	if (!prop || len < mem_size_cells * sizeof(__be32)) {
>   		pr_info("Could not determine LMB size\n");
>   		return -1;
>   	}
>   
> -	drmem_info->lmb_size = of_read_number(prop, n_root_size_cells);
> +	drmem_info->lmb_size = of_read_number(prop, mem_size_cells);
>   	return 0;
>   }
>   
> @@ -353,12 +347,6 @@ int walk_drmem_lmbs(struct device_node *dn, void *data,
>   	if (!of_root)
>   		return ret;
>   
> -	/* Get the address & size cells */
> -	of_node_get(of_root);
> -	n_root_addr_cells = of_n_addr_cells(of_root);
> -	n_root_size_cells = of_n_size_cells(of_root);
> -	of_node_put(of_root);
> -
>   	if (init_drmem_lmb_size(dn))
>   		return ret;
>   
> 

Thanks
Hari
diff mbox series

Patch

diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index b2eeea39684c..f533a7b04ab9 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -14,8 +14,6 @@ 
 #include <asm/prom.h>
 #include <asm/drmem.h>
 
-static int n_root_addr_cells, n_root_size_cells;
-
 static struct drmem_lmb_info __drmem_info;
 struct drmem_lmb_info *drmem_info = &__drmem_info;
 
@@ -196,8 +194,8 @@  static void read_drconf_v1_cell(struct drmem_lmb *lmb,
 {
 	const __be32 *p = *prop;
 
-	lmb->base_addr = of_read_number(p, n_root_addr_cells);
-	p += n_root_addr_cells;
+	lmb->base_addr = of_read_number(p, mem_addr_cells);
+	p += mem_addr_cells;
 	lmb->drc_index = of_read_number(p++, 1);
 
 	p++; /* skip reserved field */
@@ -233,8 +231,8 @@  static void read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
 	const __be32 *p = *prop;
 
 	dr_cell->seq_lmbs = of_read_number(p++, 1);
-	dr_cell->base_addr = of_read_number(p, n_root_addr_cells);
-	p += n_root_addr_cells;
+	dr_cell->base_addr = of_read_number(p, mem_addr_cells);
+	p += mem_addr_cells;
 	dr_cell->drc_index = of_read_number(p++, 1);
 	dr_cell->aa_index = of_read_number(p++, 1);
 	dr_cell->flags = of_read_number(p++, 1);
@@ -285,10 +283,6 @@  int __init walk_drmem_lmbs_early(unsigned long node, void *data,
 	if (!prop || len < dt_root_size_cells * sizeof(__be32))
 		return ret;
 
-	/* Get the address & size cells */
-	n_root_addr_cells = dt_root_addr_cells;
-	n_root_size_cells = dt_root_size_cells;
-
 	drmem_info->lmb_size = dt_mem_next_cell(dt_root_size_cells, &prop);
 
 	usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", &len);
@@ -318,12 +312,12 @@  static int init_drmem_lmb_size(struct device_node *dn)
 		return 0;
 
 	prop = of_get_property(dn, "ibm,lmb-size", &len);
-	if (!prop || len < n_root_size_cells * sizeof(__be32)) {
+	if (!prop || len < mem_size_cells * sizeof(__be32)) {
 		pr_info("Could not determine LMB size\n");
 		return -1;
 	}
 
-	drmem_info->lmb_size = of_read_number(prop, n_root_size_cells);
+	drmem_info->lmb_size = of_read_number(prop, mem_size_cells);
 	return 0;
 }
 
@@ -353,12 +347,6 @@  int walk_drmem_lmbs(struct device_node *dn, void *data,
 	if (!of_root)
 		return ret;
 
-	/* Get the address & size cells */
-	of_node_get(of_root);
-	n_root_addr_cells = of_n_addr_cells(of_root);
-	n_root_size_cells = of_n_size_cells(of_root);
-	of_node_put(of_root);
-
 	if (init_drmem_lmb_size(dn))
 		return ret;