* [PATCH v5 1/3] of: Do not expose of_alias_scan() and correct its comments
2025-01-14 15:23 [PATCH v5 0/3] of: fix bugs and improve codes Zijun Hu
@ 2025-01-14 15:23 ` Zijun Hu
2025-01-14 15:23 ` [PATCH v5 2/3] of: reserved-memory: Warn for missing static reserved memory regions Zijun Hu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2025-01-14 15:23 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Oreoluwa Babatunde
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
of_alias_scan() has no external callers and returns void.
Do not expose it and delete return value descriptions in its comments.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
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(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 969b99838655534915882abe358814d505c6f748..f4ab4086b80f62c4d9ce428cdde042d0ed4febe2 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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))
{
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 58819222279a5319c5f6be30d156b24f920c5481..f3e1193c8ded4899f39677a76da073e2266a1b9a 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -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.
*
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
index 7eda43c66c916198b1c2d8fc5043fcb1edaede7a..cb0cb374b21ff89323e11f34bd767b183e7a401e 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -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)
diff --git a/include/linux/of.h b/include/linux/of.h
index 0cdd58ff0a4190724309ba1eddbac51b188b6136..eaf0e2a2b75cbe4769a77f68965298c84d57e62c 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v5 2/3] of: reserved-memory: Warn for missing static reserved memory regions
2025-01-14 15:23 [PATCH v5 0/3] of: fix bugs and improve codes Zijun Hu
2025-01-14 15:23 ` [PATCH v5 1/3] of: Do not expose of_alias_scan() and correct its comments Zijun Hu
@ 2025-01-14 15:23 ` Zijun Hu
2025-01-14 15:23 ` [PATCH v5 3/3] of: Correct element count for two arrays in API of_parse_phandle_with_args_map() Zijun Hu
2025-01-17 14:53 ` [PATCH v5 0/3] of: fix bugs and improve codes Rob Herring (Arm)
3 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2025-01-14 15:23 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Oreoluwa Babatunde
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu, stable
From: Zijun Hu <quic_zijuhu@quicinc.com>
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.
Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/of_reserved_mem.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 17c57118c4960d8ac502add1904f7f464258f5a1..75e819f66a56139a800dba5e2e0044d0bbeb065e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v5 3/3] of: Correct element count for two arrays in API of_parse_phandle_with_args_map()
2025-01-14 15:23 [PATCH v5 0/3] of: fix bugs and improve codes Zijun Hu
2025-01-14 15:23 ` [PATCH v5 1/3] of: Do not expose of_alias_scan() and correct its comments Zijun Hu
2025-01-14 15:23 ` [PATCH v5 2/3] of: reserved-memory: Warn for missing static reserved memory regions Zijun Hu
@ 2025-01-14 15:23 ` Zijun Hu
2025-01-17 14:53 ` [PATCH v5 0/3] of: fix bugs and improve codes Rob Herring (Arm)
3 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2025-01-14 15:23 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Oreoluwa Babatunde
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
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.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/base.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index f4ab4086b80f62c4d9ce428cdde042d0ed4febe2..2432e0f4646d1d829d5b94ae2d2b1717afe286cf 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v5 0/3] of: fix bugs and improve codes
2025-01-14 15:23 [PATCH v5 0/3] of: fix bugs and improve codes Zijun Hu
` (2 preceding siblings ...)
2025-01-14 15:23 ` [PATCH v5 3/3] of: Correct element count for two arrays in API of_parse_phandle_with_args_map() Zijun Hu
@ 2025-01-17 14:53 ` Rob Herring (Arm)
3 siblings, 0 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2025-01-17 14:53 UTC (permalink / raw)
To: Zijun Hu
Cc: Oreoluwa Babatunde, Zijun Hu, devicetree, stable, linux-kernel,
Saravana Kannan
On Tue, 14 Jan 2025 23:23:02 +0800, Zijun Hu wrote:
> This patch series is to fix bugs and improve codes for drivers/of/*.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> Changes in v5:
> - Drop 12 patches and add 1 patch
> - Correct based on Rob's comments
> - Link to v4: https://lore.kernel.org/r/20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com
>
> Changes in v4:
> - Remove 2 modalias relevant patches, and add more patches.
> - Link to v3: https://lore.kernel.org/r/20241217-of_core_fix-v3-0-3bc49a2e8bda@quicinc.com
>
> 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/20241216-of_core_fix-v2-0-e69b8f60da63@quicinc.com
>
> Changes in v2:
> - Drop applied/conflict/TBD patches.
> - Correct based on Rob's comments.
> - Link to v1: https://lore.kernel.org/r/20241206-of_core_fix-v1-0-dc28ed56bec3@quicinc.com
>
> ---
> 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,
> --
> Zijun Hu <quic_zijuhu@quicinc.com>
>
>
>
Applied, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread