[PATCH 3/3] memtest: remove use of vu_long typedef in mem_test_alt

Rasmus Villemoes ravi at prevas.dk
Fri Aug 22 20:18:48 CEST 2025


Hiding a qualifier such as "volatile" inside a typedef makes the code
much harder to understand. Since addr and dummy being
volatile-qualified are important for the correctness of the test code,
make it more obvious by spelling it out as "volatile ulong".

Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
---
 cmd/mem.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/cmd/mem.c b/cmd/mem.c
index 013e93f09df..c8c602ec9c4 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -710,10 +710,10 @@ static int do_mem_loopw(struct cmd_tbl *cmdtp, int flag, int argc,
 #endif /* CONFIG_LOOPW */
 
 #ifdef CONFIG_CMD_MEMTEST
-static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
-			  vu_long *dummy)
+static ulong mem_test_alt(volatile ulong *buf, ulong start_addr, ulong end_addr,
+			  volatile ulong *dummy)
 {
-	vu_long *addr;
+	volatile ulong *addr;
 	ulong errs = 0;
 	ulong val, readback;
 	int j;
@@ -733,7 +733,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 	/* Rate-limit schedule() calls to one for every 256 words. */
 	u8 count = 0;
 
-	num_words = (end_addr - start_addr) / sizeof(vu_long);
+	num_words = (end_addr - start_addr) / sizeof(ulong);
 
 	/*
 	 * Data line test: write a pattern to the first
@@ -815,8 +815,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 	 *
 	 * Returns:     0 if the test succeeds, 1 if the test fails.
 	 */
-	pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
-	anti_pattern = (vu_long)0x5555555555555555;
+	pattern = (ulong)0xaaaaaaaaaaaaaaaa;
+	anti_pattern = (ulong)0x5555555555555555;
 
 	debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
 	/*
@@ -837,7 +837,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 		if (temp != pattern) {
 			printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
 				" expected 0x%.8lx, actual 0x%.8lx\n",
-				start_addr + offset*sizeof(vu_long),
+				start_addr + offset*sizeof(ulong),
 				pattern, temp);
 			errs++;
 			if (ctrlc())
@@ -859,7 +859,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 				printf("\nFAILURE: Address bit stuck low or"
 					" shorted @ 0x%.8lx: expected 0x%.8lx,"
 					" actual 0x%.8lx\n",
-					start_addr + offset*sizeof(vu_long),
+					start_addr + offset*sizeof(ulong),
 					pattern, temp);
 				errs++;
 				if (ctrlc())
@@ -902,7 +902,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 		if (temp != pattern) {
 			printf("\nFAILURE (read/write) @ 0x%.8lx:"
 				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				start_addr + offset*sizeof(vu_long),
+				start_addr + offset*sizeof(ulong),
 				pattern, temp);
 			errs++;
 			if (ctrlc())
@@ -924,7 +924,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
 		if (temp != anti_pattern) {
 			printf("\nFAILURE (read/write): @ 0x%.8lx:"
 				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				start_addr + offset*sizeof(vu_long),
+				start_addr + offset*sizeof(ulong),
 				anti_pattern, temp);
 			errs++;
 			if (ctrlc())
-- 
2.50.1



More information about the U-Boot mailing list