Skip to contentSkip to conversation

of: fix bugs and improve codes

PATCH Applied Zijun Hu 2 participants 5 messages Jan 14, 2025 – Jan 17, 2025

Subsystems (2)
lore
Share & tools
lore

Zijun Hu

author
#0 lore raw

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]>
author
#1 lore raw

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
index 969b99838655534915882abe358814d505c6f748..f4ab4086b80f62c4d9ce428cdde042d0ed4febe2 100644
@@ -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
index 58819222279a5319c5f6be30d156b24f920c5481..f3e1193c8ded4899f39677a76da073e2266a1b9a 100644
@@ -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
index 7eda43c66c916198b1c2d8fc5043fcb1edaede7a..cb0cb374b21ff89323e11f34bd767b183e7a401e 100644
@@ -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
index 0cdd58ff0a4190724309ba1eddbac51b188b6136..eaf0e2a2b75cbe4769a77f68965298c84d57e62c 100644
@@ -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
author
#2 lore raw

PATCH v5 2/3 of: reserved-memory: Warn for missing static reserved memory regions

In reply to Zijun Hu

From: 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.

Fixes 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed")
---
 drivers/of/of_reserved_mem.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/of/of_reserved_mem.c +5 -0
index 17c57118c4960d8ac502add1904f7f464258f5a1..75e819f66a56139a800dba5e2e0044d0bbeb065e 100644
@@ -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
author
#3 lore raw

PATCH v5 3/3 of: Correct element count for two arrays in API of_parse_phandle_with_args_map()

In reply to Zijun Hu

From: 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
index f4ab4086b80f62c4d9ce428cdde042d0ed4febe2..2432e0f4646d1d829d5b94ae2d2b1717afe286cf 100644
@@ -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
maintainer Applied
#4 lore raw
In reply to Zijun Hu
Quoted 37 lines · Zijun Hu

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(-)
Quoted 10 lines

---
base-commit: c141ecc3cecd764799e17c8251026336cab86800
change-id: 20241206-of_core_fix-dc3021a06418

Best regards,
--
Zijun Hu <[email protected]>

Applied, thanks!