of/fdt: Some bug fixes and cleanups
Subsystems (2)
cover of/fdt: Some bug fixes and cleanups
This patch series fixes several bugs related to dt_root_addr_cells and dt_root_size_cells, and performs some cleanup.
Links to the previous related patches:
https://lore.kernel.org/lkml/CAL_JsqJxar7z+VcBXwPTw5-Et2oC9bQmH_CtMtKhoo_-=zN2XQ@mail.gmail.com/
Yuntao Wang (10):
of/fdt: Introduce dt_root_addr_size_cells() and
dt_root_addr_size_bytes()
of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
it
of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
it
of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
it
of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr() of/fdt: Fix the len check in
early_init_dt_check_for_usable_mem_range()
of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it of/fdt: Fix incorrect use of dt_root_addr_cells in
early_init_dt_check_kho()
of/address: Remove the incorrect and misleading comment
drivers/of/address.c | 4 ---- drivers/of/fdt.c | 14 +++++++------- drivers/of/of_reserved_mem.c | 6 +++--- include/linux/of_fdt.h | 11 +++++++++++ 4 files changed, 21 insertions(+), 14 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/10 of/fdt: Introduce dt_root_addr_size_cells() and dt_root_addr_size_bytes()
Currently, many places use the result of the expression (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32) for various checks.
To improve code maintainability and reduce the chance of errors, extract this expression into two helper functions.
--- include/linux/of_fdt.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/of_fdt.h +11 -0
@@ -30,6 +30,17 @@ extern void *of_fdt_unflatten_tree(const unsigned long *blob,/* TBD: Temporary export of fdt globals - remove when code fully merged */ extern int __initdata dt_root_addr_cells;extern int __initdata dt_root_size_cells; + +static inline int dt_root_addr_size_cells (void ) +{ +return dt_root_addr_cells + dt_root_size_cells; +} + +static inline int dt_root_addr_size_bytes (void ) +{ +return dt_root_addr_size_cells () *sizeof (__be32); +} +extern void *initial_boot_params;extern phys_addr_t initial_boot_params_pa;
Signature · 1 line
2.51.0
Re: [PATCH 01/10] of/fdt: Introduce dt_root_addr_size_cells() and dt_root_addr_size_bytes()
Quoted 8 lines · Yuntao Wang
Currently, many places use the result of the expression
(dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32)for various checks.To improve code maintainability and reduce the chance of errors, extract this expression into two helper functions.
Signed-off-by Yuntao Wang <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 2/10 of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao WangUse dt_root_addr_size_bytes() instead of open-coding it in __reserved_mem_reserve_reg() to improve code maintainability.
--- drivers/of/of_reserved_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/of_reserved_mem.c +1 -1
@@ -154,7 +154,7 @@ static int __init early_init_dt_reserve_memory(phys_addr_t base,static int __init __reserved_mem_reserve_reg (unsigned long node,const char *uname) { -int t_len = (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32); +int t_len =dt_root_addr_size_bytes ();phys_addr_t base, size;int len;const __be32 *prop;
Signature · 1 line
2.51.0
Re: [PATCH 02/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
Quoted 4 lines · Yuntao Wang
Use
dt_root_addr_size_bytes()instead of open-coding it in__reserved_mem_reserve_reg()to improve code maintainability.Signed-off-by Yuntao Wang <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 3/10 of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao WangUse dt_root_addr_size_bytes() instead of open-coding it in fdt_scan_reserved_mem_reg_nodes() to improve code maintainability.
--- drivers/of/of_reserved_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/of_reserved_mem.c +1 -1
@@ -230,7 +230,7 @@ static void __init __rmem_check_for_overlap(void);*/ void __init fdt_scan_reserved_mem_reg_nodes (void ) { -int t_len = (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32); +int t_len =dt_root_addr_size_bytes ();const void *fdt = initial_boot_params;phys_addr_t base, size;const __be32 *prop;
Signature · 1 line
2.51.0
Re: [PATCH 03/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
Quoted 4 lines · Yuntao Wang
Use
dt_root_addr_size_bytes()instead of open-coding it infdt_scan_reserved_mem_reg_nodes()to improve code maintainability.Signed-off-by Yuntao Wang <[email protected]>
But please combine with the previous patch with the same subject.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 4/10 of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao WangUse dt_root_addr_size_bytes() instead of open-coding it in __reserved_mem_alloc_size() to improve code maintainability.
--- drivers/of/of_reserved_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/of_reserved_mem.c +1 -1
@@ -401,7 +401,7 @@ static int __init __reserved_mem_alloc_in_range(phys_addr_t size,*/ static int __init __reserved_mem_alloc_size (unsigned long node,const char *uname) { -int t_len = (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32); +int t_len =dt_root_addr_size_bytes ();phys_addr_t start =0 , end =0 ;phys_addr_t base =0 , align =0 , size;int len;
Signature · 1 line
2.51.0
Re: [PATCH 04/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
Quoted 4 lines · Yuntao Wang
Use
dt_root_addr_size_bytes()instead of open-coding it in__reserved_mem_alloc_size()to improve code maintainability.Signed-off-by Yuntao Wang <[email protected]>
But please combine with the previous patch with the same subject.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
kernel test robot
build botRe: [PATCH 04/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao Wangkernel test robot noticed the following build warnings:
Hi Yuntao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.18-rc5 next-20251113] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yuntao-Wang/of-fdt-Introduce-dt_root_addr_size_cells-and-dt_root_addr_size_bytes/20251112-232000 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20251112143520.233870-5-yuntao.wang%40linux.dev patch subject: [PATCH 04/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it config: nios2-randconfig-002-20251113 (https://download.01.org/0day-ci/archive/20251113/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251113/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0x0 (section: .text.unlikely) -> dt_root_addr_cells (section: .init.data) >> WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0x4 (section: .text.unlikely) -> dt_root_size_cells (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0x8 (section: .text.unlikely) -> dt_root_addr_cells (section: .init.data)
WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0xc (section: .text.unlikely) -> dt_root_size_cells (section: .init.data)
ERROR: modpost: "__divsi3_table" [lib/lz4/lz4_compress.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 04/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao Wangkernel test robot noticed the following build warnings:
Hi Yuntao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.18-rc5 next-20251113] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yuntao-Wang/of-fdt-Introduce-dt_root_addr_size_cells-and-dt_root_addr_size_bytes/20251112-232000 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20251112143520.233870-5-yuntao.wang%40linux.dev patch subject: [PATCH 04/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it config: i386-randconfig-011-20251114 (https://download.01.org/0day-ci/archive/20251114/[email protected]/config) compiler: gcc-12 (Debian 12.4.0-5) 12.4.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251114/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0x1 (section: .text) -> dt_root_size_cells (section: .init.data) >> WARNING: modpost: vmlinux: section mismatch in reference: dt_root_addr_size_bytes+0x7 (section: .text) -> dt_root_addr_cells (section: .init.data)
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 5/10 of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao WangUse dt_root_addr_size_bytes() instead of open-coding it in of_fdt_limit_memory() to improve code maintainability.
--- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -52,7 +52,7 @@ void __init of_fdt_limit_memory(int limit)int memory;int len;const void *val; -int cell_size =sizeof (uint32_t )*(dt_root_addr_cells + dt_root_size_cells); +int cell_size =dt_root_addr_size_bytes (); memory =fdt_path_offset (initial_boot_params,"/memory" );if (memory >0 ) {
Signature · 1 line
2.51.0
Re: [PATCH 05/10] of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
Quoted 4 lines · Yuntao Wang
Use
dt_root_addr_size_bytes()instead of open-coding it inof_fdt_limit_memory()to improve code maintainability.Signed-off-by Yuntao Wang <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 6/10 of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr()
In reply to Yuntao WangThe len value is in bytes, while dt_root_addr_cells + dt_root_size_cells is in cells (4 bytes per cell).
Comparing them directly is incorrect. Convert units before comparison.
--- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -821,7 +821,7 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)pr_debug ("Looking for elfcorehdr property... " ); prop =of_get_flat_dt_prop (node,"linux,elfcorehdr" , &len); -if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) +if (!prop || len <dt_root_addr_size_bytes ())return ; elfcorehdr_addr =dt_mem_next_cell (dt_root_addr_cells, &prop);
Signature · 1 line
2.51.0
PATCH 7/10 of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()
In reply to Yuntao WangThe len value is in bytes, while dt_root_addr_cells + dt_root_size_cells is in cells (4 bytes per cell).
The modulo calculation between them is incorrect, the units must be converted first.
--- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -859,7 +859,7 @@ void __init early_init_dt_check_for_usable_mem_range(void)pr_debug ("Looking for usable-memory-range property... " ); prop =of_get_flat_dt_prop (node,"linux,usable-memory-range" , &len); -if (!prop || (len % (dt_root_addr_cells + dt_root_size_cells))) +if (!prop || len %dt_root_addr_size_bytes ())return ; endp = prop + (len /sizeof (__be32));
Signature · 1 line
2.51.0
Re: [PATCH 07/10] of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()
Hi Yuntao,
Quoted 5 lines · Yuntao Wang
The len value is in bytes, while
dt_root_addr_cells + dt_root_size_cellsis in cells (4 bytes per cell).The modulo calculation between them is incorrect, the units must be converted first.
Thanks for your patch!
Quoted 1 line
Fixes fb319e77a0e7 ("of: fdt: Add memory for devices by DT property "linux,usable-memory-range"")
That commit merely changed "<" to "%".
The code that added the bad expression was:
usable memory range property")
However, that code was copied from:
property, usable-memory-range")
So I think you want to list these two Fixes-tags instead.
Quoted 1 line
Signed-off-by Yuntao Wang <[email protected]>
For the actual change:
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 8/10 of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
In reply to Yuntao WangUse dt_root_addr_size_bytes() instead of open-coding it in early_init_dt_check_kho() to improve code maintainability.
--- drivers/of/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/fdt.c +2 -2
@@ -890,14 +890,14 @@ static void __init early_init_dt_check_kho(void)return ; p =of_get_flat_dt_prop (node,"linux,kho-fdt" , &l); -if (l != (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32)) +if (l !=dt_root_addr_size_bytes ())return ; fdt_start =dt_mem_next_cell (dt_root_addr_cells, &p); fdt_size =dt_mem_next_cell (dt_root_addr_cells, &p); p =of_get_flat_dt_prop (node,"linux,kho-scratch" , &l); -if (l != (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32)) +if (l !=dt_root_addr_size_bytes ())return ; scratch_start =dt_mem_next_cell (dt_root_addr_cells, &p);
Signature · 1 line
2.51.0
Re: [PATCH 08/10] of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
Quoted 4 lines · Yuntao Wang
Use
dt_root_addr_size_bytes()instead of open-coding it inearly_init_dt_check_kho()to improve code maintainability.Signed-off-by Yuntao Wang <[email protected]>
But please combine with the other patch with the same subject.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 9/10 of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho()
In reply to Yuntao WangWhen reading the fdt_size value, the argument passed to dt_mem_next_cell() is dt_root_addr_cells, but it should be dt_root_size_cells.
The same issue occurs when reading the scratch_size value.
Fix these issues.
--- drivers/of/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/fdt.c +2 -2
@@ -894,14 +894,14 @@ static void __init early_init_dt_check_kho(void)return ; fdt_start =dt_mem_next_cell (dt_root_addr_cells, &p); - fdt_size =dt_mem_next_cell (dt_root_addr_cells, &p); + fdt_size =dt_mem_next_cell (dt_root_size_cells, &p); p =of_get_flat_dt_prop (node,"linux,kho-scratch" , &l);if (l !=dt_root_addr_size_bytes ())return ; scratch_start =dt_mem_next_cell (dt_root_addr_cells, &p); - scratch_size =dt_mem_next_cell (dt_root_addr_cells, &p); + scratch_size =dt_mem_next_cell (dt_root_size_cells, &p);kho_populate (fdt_start, fdt_size, scratch_start, scratch_size); }
Signature · 1 line
2.51.0
Re: [PATCH 09/10] of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho()
Hi Yuntao,
Quoted 9 lines · Yuntao Wang
When reading the
fdt_sizevalue, the argument passed todt_mem_next_cell()isdt_root_addr_cells, but it should bedt_root_size_cells.The same issue occurs when reading the
scratch_sizevalue.Fix these issues.
Fixes 274cdcb1c004 ("arm64: add KHO support")Signed-off-by Yuntao Wang <[email protected]>
Thanks for your patch!
drivers/of/fdt.c static void __init early_init_dt_check_kho(void) · line 897
Quoted 8 lines
drivers/of/fdt.c +1
-1@@ -894,14 +894,14 @@ static void __init early_init_dt_check_kho(void)return ; fdt_start =dt_mem_next_cell (dt_root_addr_cells, &p); - fdt_size =dt_mem_next_cell (dt_root_addr_cells, &p); + fdt_size =dt_mem_next_cell (dt_root_size_cells, &p);
I think it would be worthwhile to have separate dt_mem_next_addr_cell() and dt_mem_next_size_cell() helpers. That would us bring a few steps closer to the following goal stated in <linux/of_fdt.h>:
/* TBD: Temporary export of fdt globals - remove when code fully merged */
extern int __initdata dt_root_addr_cells;
extern int __initdata dt_root_size_cells;drivers/of/fdt.c static void __init early_init_dt_check_kho(void) · line 907
Quoted 11 lines
drivers/of/fdt.c +1
-1p =of_get_flat_dt_prop (node,"linux,kho-scratch" , &l);if (l !=dt_root_addr_size_bytes ())return ; scratch_start =dt_mem_next_cell (dt_root_addr_cells, &p); - scratch_size =dt_mem_next_cell (dt_root_addr_cells, &p); + scratch_size =dt_mem_next_cell (dt_root_size_cells, &p);kho_populate (fdt_start, fdt_size, scratch_start, scratch_size); }
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 10/10 of/address: Remove the incorrect and misleading comment
In reply to Yuntao WangThe of_bus_default_match() function appears to have been copied from of_bus_default_flags_match() with some modifications.
However, the comment was left unchanged and still describes the behavior of of_bus_default_flags_match(), it is incorrect and misleading, remove it.
--- drivers/of/address.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/of/address.c +0 -4
@@ -328,10 +328,6 @@ static int of_bus_default_flags_match(struct device_node *np)static int of_bus_default_match (struct device_node *np) { -/* -* Check for presence first since of_bus_n_addr_cells() will warn when -* walking parent nodes. -*/ return of_property_present (np,"#address-cells" ); }
Signature · 1 line
2.51.0
Re: [PATCH 10/10] of/address: Remove the incorrect and misleading comment
Quoted 7 lines · Yuntao Wang
The
of_bus_default_match()function appears to have been copied fromof_bus_default_flags_match()with some modifications.However, the comment was left unchanged and still describes the behavior of
of_bus_default_flags_match(), it is incorrect and misleading, remove it.Signed-off-by Yuntao Wang <[email protected]>
translating non-translatable addresses")
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Rob Herring
maintainerRe: [PATCH 10/10] of/address: Remove the incorrect and misleading comment
In reply to Yuntao WangQuoted 5 lines · Yuntao Wang
The
of_bus_default_match()function appears to have been copied fromof_bus_default_flags_match()with some modifications.However, the comment was left unchanged and still describes the behavior of
of_bus_default_flags_match(), it is incorrect and misleading, remove it.
There is no reason to put this patch in this series. It is completely unrelated.
Quoted 24 lines
Signed-off-by Yuntao Wang <[email protected]>--- drivers/of/address.c | 4 ---- 1 file changed, 4 deletions(-)drivers/of/address.c +0
-4@@ -328,10 +328,6 @@ static int of_bus_default_flags_match(struct device_node *np)static int of_bus_default_match (struct device_node *np) { -/* -* Check for presence first since of_bus_n_addr_cells() will warn when -* walking parent nodes. -*/ return of_property_present (np,"#address-cells" ); }Signature · 1 line
2.51.0
Re: [PATCH 10/10] of/address: Remove the incorrect and misleading comment
In reply to Yuntao WangQuoted 10 lines · Yuntao Wang
The
of_bus_default_match()function appears to have been copied fromof_bus_default_flags_match()with some modifications.However, the comment was left unchanged and still describes the behavior of
of_bus_default_flags_match(), it is incorrect and misleading, remove it.Signed-off-by Yuntao Wang <[email protected]>--- drivers/of/address.c | 4 ---- 1 file changed, 4 deletions(-)
Applied, thanks!
Rob Herring
maintainerQuoted 7 lines · Yuntao Wang
This patch series fixes several bugs related to
dt_root_addr_cellsanddt_root_size_cells, and performs some cleanup.Links to the previous related patches:
https://lore.kernel.org/lkml/CAL_JsqJxar7z+VcBXwPTw5-Et2oC9bQmH_CtMtKhoo_-=zN2XQ@mail.gmail.com/
Quoted 9 lines
Yuntao Wang (10):
of/fdt: Introducedt_root_addr_size_cells()and
dt_root_addr_size_bytes()
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
it
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
it
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
it
Your aim in writing subjects should be to write something that is unique for every commit in the past or future. Because you can never make the same change twice, right? (I'm excluding 'fix typos/spelling' type commits). Certainly the same subject in one series is never right.
Quoted 5 lines
of/fdt: Use
dt_root_addr_size_bytes()instead of open-coding it of/fdt: Fix the len check inearly_init_dt_check_for_elfcorehdr()of/fdt: Fix the len check in
early_init_dt_check_for_usable_mem_range()
of/fdt: Usedt_root_addr_size_bytes()instead of open-coding it
This is not what I meant. We have multiple copies of this where only the property name changes:
prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) return; elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop);
Instead, add a function something like this:
static void early_init_dt_read_address(unsigned long node, const char *prop, u64 *addr, u64*size)
{
prop = of_get_flat_dt_prop(node, prop, &len);
if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells)))
return;
*addr = dt_mem_next_cell(dt_root_addr_cells, &prop);
*size = dt_mem_next_cell(dt_root_size_cells, &prop);
}Then we only have the length checks in one place.
That still leaves the cases with more than 1 entry open coded. So instead, to cover that case to something like this:
const __be32 *of_get_flat_dt_address_prop(unsigned long node, const char *propname, int *len)
{
prop = of_get_flat_dt_prop(node, propname, &len);
if (!prop || (*len % (dt_root_addr_cells + dt_root_size_cells))) {
*len = 0;
return NULL;
}
*len /= (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
return prop;
}And then a user would look something like this:
prop = of_get_flat_dt_address(node, "linux,usable-memory-range", &len);
for (i = 0; i < len; i++) {
of_read_address_idx(prop, i, &addr, &size);
...
}Here 'len' is number of addr+size entries.
And the simple case of reading 1 entry could be just:
of_read_address_idx(of_get_flat_dt_address(node, "linux,elfcorehdr", NULL), 0, &addr, &size);
Rob
Quoted 79 lines · Rob Herring
Quoted 7 lines · Yuntao Wang
This patch series fixes several bugs related to
dt_root_addr_cellsanddt_root_size_cells, and performs some cleanup.Links to the previous related patches:
https://lore.kernel.org/lkml/CAL_JsqJxar7z+VcBXwPTw5-Et2oC9bQmH_CtMtKhoo_-=zN2XQ@mail.gmail.com/
Quoted 9 lines
Yuntao Wang (10):
of/fdt: Introducedt_root_addr_size_cells()and
dt_root_addr_size_bytes()
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
it
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
it
of/reserved_mem: Usedt_root_addr_size_bytes()instead of open-coding
itYour aim in writing subjects should be to write something that is unique for every commit in the past or future. Because you can never make the same change twice, right? (I'm excluding 'fix typos/spelling' type commits). Certainly the same subject in one series is never right.
Quoted 5 lines
of/fdt: Use
dt_root_addr_size_bytes()instead of open-coding it of/fdt: Fix the len check inearly_init_dt_check_for_elfcorehdr()of/fdt: Fix the len check in
early_init_dt_check_for_usable_mem_range()
of/fdt: Usedt_root_addr_size_bytes()instead of open-coding itThis is not what I meant. We have multiple copies of this where only the property name changes:
prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) return; elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop);Instead, add a function something like this:
static void
early_init_dt_read_address(unsigned long node, const char *prop, u64 *addr, u64*size){ prop = of_get_flat_dt_prop(node, prop, &len); if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) return; *addr = dt_mem_next_cell(dt_root_addr_cells, &prop); *size = dt_mem_next_cell(dt_root_size_cells, &prop); }Then we only have the length checks in one place.
That still leaves the cases with more than 1 entry open coded. So instead, to cover that case to something like this:
const
__be32*of_get_flat_dt_address_prop(unsigned long node, const char *propname, int *len){ prop = of_get_flat_dt_prop(node, propname, &len); if (!prop || (*len % (dt_root_addr_cells + dt_root_size_cells))) { *len = 0; return NULL; } *len /= (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); return prop; }And then a user would look something like this:
prop =
of_get_flat_dt_address(node, "linux,usable-memory-range", &len);for (i = 0; i < len; i++) { of_read_address_idx(prop, i, &addr, &size); ... }
Quoted 7 lines
Here 'len' is number of addr+size entries.
And the simple case of reading 1 entry could be just:
of_read_address_idx(of_get_flat_dt_address(node, "linux,elfcorehdr", NULL), 0, &addr, &size);Rob
Hi Rob,
The link to the new patch series:
https://lore.kernel.org/linux-devicetree/[email protected]/t/
Thanks,
Yuntao