diff mbox series

[2/3] of/fdt: avoid re-parsing '#{address,size}-cells' in of_fdt_limit_memory

Message ID 20180830190523.31474-3-robh@kernel.org
State New
Headers show
Series None | expand

Commit Message

Rob Herring (Arm) Aug. 30, 2018, 7:05 p.m. UTC
Now that we initialize dt_root_addr_cells and dt_root_size_cells earlier,
use them and simplify of_fdt_limit_memory.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>

---
 drivers/of/fdt.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

-- 
2.17.1

Comments

kernel test robot Sept. 1, 2018, 2:41 a.m. UTC | #1
Hi Rob,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on v4.19-rc1 next-20180831]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Rob-Herring/of-root-size-address-cells-clean-ups/20180831-160759
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

>> WARNING: vmlinux.o(.text+0x718907): Section mismatch in reference from the function of_fdt_limit_memory() to the variable .init.data:dt_root_addr_cells

   The function of_fdt_limit_memory() references
   the variable __initdata dt_root_addr_cells.
   This is often because of_fdt_limit_memory lacks a __initdata
   annotation or the annotation of dt_root_addr_cells is wrong.
--
>> WARNING: vmlinux.o(.text+0x718917): Section mismatch in reference from the function of_fdt_limit_memory() to the variable .init.data:dt_root_size_cells

   The function of_fdt_limit_memory() references
   the variable __initdata dt_root_size_cells.
   This is often because of_fdt_limit_memory lacks a __initdata
   annotation or the annotation of dt_root_size_cells is wrong.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Frank Rowand Sept. 5, 2018, 1:54 a.m. UTC | #2
On 08/30/18 12:05, Rob Herring wrote:
> Now that we initialize dt_root_addr_cells and dt_root_size_cells earlier,

> use them and simplify of_fdt_limit_memory.

> 

> Cc: Frank Rowand <frowand.list@gmail.com>

> Signed-off-by: Rob Herring <robh@kernel.org>

> ---

>  drivers/of/fdt.c | 23 +----------------------

>  1 file changed, 1 insertion(+), 22 deletions(-)

> 

> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c

> index 49abe18f1bde..fef4b2c8a171 100644

> --- a/drivers/of/fdt.c

> +++ b/drivers/of/fdt.c


As kbuild test robot noted, of_fdt_limit_memory() will access
__initdata dt_root_addr_cells and __initdata dt_root_size_cells.
A possible (untested) fix would be:

- void of_fdt_limit_memory(int limit)
- {

+ void __init of_fdt_limit_memory(int limit)
+ {


> @@ -44,28 +44,7 @@ void of_fdt_limit_memory(int limit)

>  	int memory;

>  	int len;

>  	const void *val;

> -	int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;

> -	int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;

> -	const __be32 *addr_prop;

> -	const __be32 *size_prop;

> -	int root_offset;

> -	int cell_size;

> -

> -	root_offset = fdt_path_offset(initial_boot_params, "/");

> -	if (root_offset < 0)

> -		return;

> -

> -	addr_prop = fdt_getprop(initial_boot_params, root_offset,

> -				"#address-cells", NULL);

> -	if (addr_prop)

> -		nr_address_cells = fdt32_to_cpu(*addr_prop);

> -

> -	size_prop = fdt_getprop(initial_boot_params, root_offset,

> -				"#size-cells", NULL);

> -	if (size_prop)

> -		nr_size_cells = fdt32_to_cpu(*size_prop);

> -

> -	cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells);

> +	int cell_size = sizeof(uint32_t)*(dt_root_addr_cells + dt_root_size_cells);

>  

>  	memory = fdt_path_offset(initial_boot_params, "/memory");

>  	if (memory > 0) {

>
diff mbox series

Patch

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 49abe18f1bde..fef4b2c8a171 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -44,28 +44,7 @@  void of_fdt_limit_memory(int limit)
 	int memory;
 	int len;
 	const void *val;
-	int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
-	int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
-	const __be32 *addr_prop;
-	const __be32 *size_prop;
-	int root_offset;
-	int cell_size;
-
-	root_offset = fdt_path_offset(initial_boot_params, "/");
-	if (root_offset < 0)
-		return;
-
-	addr_prop = fdt_getprop(initial_boot_params, root_offset,
-				"#address-cells", NULL);
-	if (addr_prop)
-		nr_address_cells = fdt32_to_cpu(*addr_prop);
-
-	size_prop = fdt_getprop(initial_boot_params, root_offset,
-				"#size-cells", NULL);
-	if (size_prop)
-		nr_size_cells = fdt32_to_cpu(*size_prop);
-
-	cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells);
+	int cell_size = sizeof(uint32_t)*(dt_root_addr_cells + dt_root_size_cells);
 
 	memory = fdt_path_offset(initial_boot_params, "/memory");
 	if (memory > 0) {