Commit 8c86bbe00f927de0655a65e43344ca0678d1bc34
1 parent
c44d4386e6
Exists in
master
and in
53 other branches
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 <sjg@chromium.org>
Showing 1 changed file with 18 additions and 12 deletions Side-by-side Diff
common/cmd_mem.c
... | ... | @@ -626,8 +626,9 @@ |
626 | 626 | } |
627 | 627 | #endif /* CONFIG_LOOPW */ |
628 | 628 | |
629 | -static ulong mem_test_alt(vu_long *start, vu_long *end) | |
629 | +static ulong mem_test_alt(ulong start_addr, ulong end_addr) | |
630 | 630 | { |
631 | + vu_long *start, *end; | |
631 | 632 | vu_long *addr; |
632 | 633 | ulong errs = 0; |
633 | 634 | ulong val, readback; |
... | ... | @@ -655,6 +656,9 @@ |
655 | 656 | 0xaaaaaaaa, /* alternating 1/0 */ |
656 | 657 | }; |
657 | 658 | |
659 | + start = (vu_long *)start_addr; | |
660 | + end = (vu_long *)end_addr; | |
661 | + | |
658 | 662 | /* |
659 | 663 | * Data line test: write a pattern to the first |
660 | 664 | * location, write the 1's complement to a 'parking' |
... | ... | @@ -735,7 +739,7 @@ |
735 | 739 | * |
736 | 740 | * Returns: 0 if the test succeeds, 1 if the test fails. |
737 | 741 | */ |
738 | - len = ((ulong)end - (ulong)start)/sizeof(vu_long); | |
742 | + len = (end_addr - start_addr) / sizeof(vu_long); | |
739 | 743 | pattern = (vu_long) 0xaaaaaaaa; |
740 | 744 | anti_pattern = (vu_long) 0x55555555; |
741 | 745 | |
742 | 746 | |
... | ... | @@ -851,9 +855,10 @@ |
851 | 855 | return 0; |
852 | 856 | } |
853 | 857 | |
854 | -static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, | |
858 | +static ulong mem_test_quick(ulong start_addr, ulong end_addr, vu_long pattern, | |
855 | 859 | int iteration) |
856 | 860 | { |
861 | + vu_long *start, *end; | |
857 | 862 | vu_long *addr; |
858 | 863 | ulong errs = 0; |
859 | 864 | ulong incr; |
... | ... | @@ -874,6 +879,8 @@ |
874 | 879 | else |
875 | 880 | pattern = ~pattern; |
876 | 881 | } |
882 | + start = (vu_long *)start_addr; | |
883 | + end = (vu_long *)end_addr; | |
877 | 884 | printf("\rPattern %08lX Writing..." |
878 | 885 | "%12s" |
879 | 886 | "\b\b\b\b\b\b\b\b\b\b", |
... | ... | @@ -912,7 +919,7 @@ |
912 | 919 | static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, |
913 | 920 | char * const argv[]) |
914 | 921 | { |
915 | - vu_long *start, *end; | |
922 | + ulong start, end; | |
916 | 923 | int iteration_limit; |
917 | 924 | int ret; |
918 | 925 | ulong errs = 0; /* number of errors, or -1 if interrupted */ |
919 | 926 | |
920 | 927 | |
921 | 928 | |
... | ... | @@ -925,14 +932,14 @@ |
925 | 932 | #endif |
926 | 933 | |
927 | 934 | if (argc > 1) |
928 | - start = (ulong *)simple_strtoul(argv[1], NULL, 16); | |
935 | + start = simple_strtoul(argv[1], NULL, 16); | |
929 | 936 | else |
930 | - start = (ulong *)CONFIG_SYS_MEMTEST_START; | |
937 | + start = CONFIG_SYS_MEMTEST_START; | |
931 | 938 | |
932 | 939 | if (argc > 2) |
933 | - end = (ulong *)simple_strtoul(argv[2], NULL, 16); | |
940 | + end = simple_strtoul(argv[2], NULL, 16); | |
934 | 941 | else |
935 | - end = (ulong *)(CONFIG_SYS_MEMTEST_END); | |
942 | + end = CONFIG_SYS_MEMTEST_END; | |
936 | 943 | |
937 | 944 | if (argc > 3) |
938 | 945 | pattern = (ulong)simple_strtoul(argv[3], NULL, 16); |
... | ... | @@ -944,10 +951,9 @@ |
944 | 951 | else |
945 | 952 | iteration_limit = 0; |
946 | 953 | |
947 | - printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start, | |
948 | - (uint)(uintptr_t)end); | |
949 | - debug("%s:%d: start 0x%p end 0x%p\n", | |
950 | - __func__, __LINE__, start, end); | |
954 | + printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); | |
955 | + debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, | |
956 | + start, end); | |
951 | 957 | |
952 | 958 | for (iteration = 0; |
953 | 959 | !iteration_limit || iteration < iteration_limit; |