From 8c86bbe00f927de0655a65e43344ca0678d1bc34 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 24 Feb 2013 17:33:20 +0000 Subject: [PATCH] Reduce casting in mtest Use a ulong for the command arguments, and only cast to an address when needed. This fixes warnings in sandbox where pointers are typically 64 bits long. Signed-off-by: Simon Glass --- common/cmd_mem.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index f5dd56db54..12dbc1609c 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -626,8 +626,9 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif /* CONFIG_LOOPW */ -static ulong mem_test_alt(vu_long *start, vu_long *end) +static ulong mem_test_alt(ulong start_addr, ulong end_addr) { + vu_long *start, *end; vu_long *addr; ulong errs = 0; ulong val, readback; @@ -655,6 +656,9 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) 0xaaaaaaaa, /* alternating 1/0 */ }; + start = (vu_long *)start_addr; + end = (vu_long *)end_addr; + /* * Data line test: write a pattern to the first * location, write the 1's complement to a 'parking' @@ -735,7 +739,7 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) * * Returns: 0 if the test succeeds, 1 if the test fails. */ - len = ((ulong)end - (ulong)start)/sizeof(vu_long); + len = (end_addr - start_addr) / sizeof(vu_long); pattern = (vu_long) 0xaaaaaaaa; anti_pattern = (vu_long) 0x55555555; @@ -851,9 +855,10 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) return 0; } -static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, +static ulong mem_test_quick(ulong start_addr, ulong end_addr, vu_long pattern, int iteration) { + vu_long *start, *end; vu_long *addr; ulong errs = 0; ulong incr; @@ -874,6 +879,8 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, else pattern = ~pattern; } + start = (vu_long *)start_addr; + end = (vu_long *)end_addr; printf("\rPattern %08lX Writing..." "%12s" "\b\b\b\b\b\b\b\b\b\b", @@ -912,7 +919,7 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - vu_long *start, *end; + ulong start, end; int iteration_limit; int ret; ulong errs = 0; /* number of errors, or -1 if interrupted */ @@ -925,14 +932,14 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, #endif if (argc > 1) - start = (ulong *)simple_strtoul(argv[1], NULL, 16); + start = simple_strtoul(argv[1], NULL, 16); else - start = (ulong *)CONFIG_SYS_MEMTEST_START; + start = CONFIG_SYS_MEMTEST_START; if (argc > 2) - end = (ulong *)simple_strtoul(argv[2], NULL, 16); + end = simple_strtoul(argv[2], NULL, 16); else - end = (ulong *)(CONFIG_SYS_MEMTEST_END); + end = CONFIG_SYS_MEMTEST_END; if (argc > 3) pattern = (ulong)simple_strtoul(argv[3], NULL, 16); @@ -944,10 +951,9 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, else iteration_limit = 0; - printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start, - (uint)(uintptr_t)end); - debug("%s:%d: start 0x%p end 0x%p\n", - __func__, __LINE__, start, end); + printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); + debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, + start, end); for (iteration = 0; !iteration_limit || iteration < iteration_limit; -- 2.30.2