]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
memtest: remove use of vu_long typedef in mem_test_alt
authorRasmus Villemoes <ravi@prevas.dk>
Fri, 22 Aug 2025 18:18:48 +0000 (20:18 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 2 Sep 2025 20:11:36 +0000 (14:11 -0600)
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@prevas.dk>
Tested-by: Anshul Dalal <anshuld@ti.com>
cmd/mem.c

index b67368dfba507d11547cd3cb319adef3f02f7c94..d5d7ca2790bdf2d100606963c0c2d48b1c6b6978 100644 (file)
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -712,10 +712,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;
@@ -735,7 +735,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
@@ -817,8 +817,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);
        /*
@@ -839,7 +839,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())
@@ -861,7 +861,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())
@@ -904,7 +904,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())
@@ -926,7 +926,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())