of: fix bugs and improve codes
Subsystems (2)
v5 cover of: fix bugs and improve codes
This patch series is to fix bugs and improve codes for drivers/of/*.
---
Changes in v5:
- Drop 12 patches and add 1 patch
- Correct based on Rob's comments
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Remove 2 modalias relevant patches, and add more patches.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Drop 2 applied patches and pick up patch 4/7 again
- Fix build error for patch 6/7.
- Include of_private.h instead of function declaration for patch 2/7
- Correct tile and commit messages.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Drop applied/conflict/TBD patches.
- Correct based on Rob's comments.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Zijun Hu (3):
of: Do not expose of_alias_scan() and correct its comments
of: reserved-memory: Warn for missing static reserved memory regions
of: Correct element count for two arrays in API of_parse_phandle_with_args_map()
drivers/of/base.c | 7 +++---- drivers/of/of_private.h | 2 ++ drivers/of/of_reserved_mem.c | 5 +++++ drivers/of/pdt.c | 2 ++ include/linux/of.h | 1 - 5 files changed, 12 insertions(+), 5 deletions(-)
---
base-commit: c141ecc3cecd764799e17c8251026336cab86800
change-id: 20241206-of_core_fix-dc3021a06418
Best regards,
Signature · 1 line
Zijun Hu <[email protected]>
PATCH v5 1/3 of: Do not expose of_alias_scan() and correct its comments
From: Zijun Hu <[email protected]>
of_alias_scan() has no external callers and returns void. Do not expose it and delete return value descriptions in its comments.
--- drivers/of/base.c | 3 +-- drivers/of/of_private.h | 2 ++ drivers/of/pdt.c | 2 ++ include/linux/of.h | 1 - 4 files changed, 5 insertions(+), 3 deletions(-)
drivers/of/base.c +1 -2
@@ -1812,8 +1812,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,* for storing the resulting tree * * The function scans all the properties of the 'aliases' node and populates -* the global lookup table with the properties. It returns the -* number of alias properties found, or an error code in case of failure. +* the global lookup table with the properties. */ void of_alias_scan (void * (*dt_alloc)(u64 size,u64 align)) {
drivers/of/of_private.h +2 -0
@@ -119,6 +119,8 @@ extern void *__unflatten_device_tree(const void *blob,void *(*dt_alloc)(u64 size,u64 align), bool detached); +void of_alias_scan (void * (*dt_alloc)(u64 size,u64 align)); +/** * General utilities for working with live trees. *
drivers/of/pdt.c +2 -0
@@ -19,6 +19,8 @@#include <linux/of.h> #include <linux/of_pdt.h> +#include "of_private.h" +static struct of_pdt_ops *of_pdt_prom_ops__initdata ;#if defined(CONFIG_SPARC )
include/linux/of.h +0 -1
@@ -398,7 +398,6 @@ extern int of_phandle_iterator_args(struct of_phandle_iterator *it,uint32_t *args, int size); -extern void of_alias_scan (void * (*dt_alloc)(u64 size,u64 align));extern int of_alias_get_id (const struct device_node *np,const char *stem);extern int of_alias_get_highest_id (const char *stem);
Signature · 1 line
2.34.1
PATCH v5 2/3 of: reserved-memory: Warn for missing static reserved memory regions
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
For child node of /reserved-memory, its property 'reg' may contain multiple regions, but fdt_scan_reserved_mem_reg_nodes() only takes into account the first region, and miss remaining regions.
But there are no simple approach to fix it, so give user warning message when miss remaining regions.
--- drivers/of/of_reserved_mem.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/of/of_reserved_mem.c +5 -0
@@ -263,6 +263,11 @@ void __init fdt_scan_reserved_mem_reg_nodes(void) uname);continue ; } + +if (len > t_len) +pr_warn ("%s() ignores %d regions in node '%s'\n" , + __func__, len / t_len -1 , uname); + base =dt_mem_next_cell (dt_root_addr_cells, &prop); size =dt_mem_next_cell (dt_root_size_cells, &prop);
Signature · 1 line
2.34.1
PATCH v5 3/3 of: Correct element count for two arrays in API of_parse_phandle_with_args_map()
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
of_parse_phandle_with_args_map() defines array @dummy_mask and @dummy_pass these two arrays only need @MAX_PHANDLE_ARGS elements separately, but they actually have (@MAX_PHANDLE_ARGS + 1) elements, One extra element doesn't hurt anything except for some stack usage.
Fix by using (@MAX_PHANDLE_ARGS - 1) as max element index in initializer.
--- drivers/of/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/base.c +2 -2
@@ -1448,8 +1448,8 @@ int of_parse_phandle_with_args_map(const struct device_node *np, char *pass_name __free(kfree) = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name);struct device_node *cur, *new =NULL ;const __be32 *map, *mask, *pass; -static const __be32 dummy_mask[] = { [0 ...MAX_PHANDLE_ARGS ] =cpu_to_be32 (~0 ) }; -static const __be32 dummy_pass[] = { [0 ...MAX_PHANDLE_ARGS ] =cpu_to_be32 (0 ) }; +static const __be32 dummy_mask[] = { [0 ... (MAX_PHANDLE_ARGS -1 )] =cpu_to_be32 (~0 ) }; +static const __be32 dummy_pass[] = { [0 ... (MAX_PHANDLE_ARGS -1 )] =cpu_to_be32 (0 ) };__be32 initial_match_array[MAX_PHANDLE_ARGS ];const __be32 *match_array = initial_match_array;int i, ret, map_len, match;
Signature · 1 line
2.34.1
Quoted 37 lines · Zijun Hu
This patch series is to fix bugs and improve codes for
drivers/of/*.Signed-off-by Zijun Hu <[email protected]>---
Changes in v5:
- Drop 12 patches and add 1 patch
- Correct based on Rob's comments
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Remove 2 modalias relevant patches, and add more patches.
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Drop 2 applied patches and pick up patch 4/7 again
- Fix build error for patch 6/7.
- Includeof_private.hinstead of function declaration for patch 2/7
- Correct tile and commit messages.
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Drop applied/conflict/TBD patches.
- Correct based on Rob's comments.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Zijun Hu (3):
of: Do not exposeof_alias_scan()and correct its comments
of: reserved-memory: Warn for missing static reserved memory regions
of: Correct element count for two arrays in APIof_parse_phandle_with_args_map()drivers/of/base.c | 7 +++---- drivers/of/of_private.h | 2 ++ drivers/of/of_reserved_mem.c | 5 +++++ drivers/of/pdt.c | 2 ++ include/linux/of.h | 1 - 5 files changed, 12 insertions(+), 5 deletions(-)
Quoted 10 lines
---
base-commit:c141ecc3cecd764799e17c8251026336cab86800
change-id: 20241206-of_core_fix-dc3021a06418Best regards,
--
Zijun Hu <[email protected]>
Applied, thanks!