]> git.sur5r.net Git - u-boot/commitdiff
Bring mtest putc() into common code
authorSimon Glass <sjg@chromium.org>
Sun, 24 Feb 2013 17:33:19 +0000 (17:33 +0000)
committerSimon Glass <sjg@chromium.org>
Fri, 1 Mar 2013 03:09:22 +0000 (19:09 -0800)
If we get a Ctrl-C abort, we always print a newline. Move this repeated
code out of the functions and into a single place in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/cmd_mem.c

index 5235bfe5812cca0dae00ae2108aa8aa61d256e7c..f5dd56db5472b194a439fd299c71a48077e4e5a7 100644 (file)
@@ -684,10 +684,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                        "expected %08lx, actual %08lx\n",
                                                val, readback);
                                errs++;
-                               if (ctrlc()) {
-                                       putc('\n');
+                               if (ctrlc())
                                        return -1;
-                               }
                        }
                        *addr  = ~val;
                        *dummy  = val;
@@ -697,10 +695,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                        "Is %08lx, should be %08lx\n",
                                                readback, ~val);
                                errs++;
-                               if (ctrlc()) {
-                                       putc('\n');
+                               if (ctrlc())
                                        return -1;
-                               }
                        }
                }
        }
@@ -765,10 +761,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                " expected 0x%.8lx, actual 0x%.8lx\n",
                                (ulong)&start[offset], pattern, temp);
                        errs++;
-                       if (ctrlc()) {
-                               putc('\n');
+                       if (ctrlc())
                                return -1;
-                       }
                }
        }
        start[test_offset] = pattern;
@@ -788,10 +782,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                        " actual 0x%.8lx\n",
                                        (ulong)&start[offset], pattern, temp);
                                errs++;
-                               if (ctrlc()) {
-                                       putc('\n');
+                               if (ctrlc())
                                        return -1;
-                               }
                        }
                }
                start[test_offset] = pattern;
@@ -830,10 +822,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                " expected 0x%.8lx, actual 0x%.8lx)\n",
                                (ulong)&start[offset], pattern, temp);
                        errs++;
-                       if (ctrlc()) {
-                               putc('\n');
+                       if (ctrlc())
                                return -1;
-                       }
                }
 
                anti_pattern = ~pattern;
@@ -852,10 +842,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end)
                                " expected 0x%.8lx, actual 0x%.8lx)\n",
                                (ulong)&start[offset], anti_pattern, temp);
                        errs++;
-                       if (ctrlc()) {
-                               putc('\n');
+                       if (ctrlc())
                                return -1;
-                       }
                }
                start[offset] = 0;
        }
@@ -907,10 +895,8 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern,
                                "found %08lX, expected %08lX\n",
                                (uint)(uintptr_t)addr, readback, val);
                        errs++;
-                       if (ctrlc()) {
-                               putc('\n');
+                       if (ctrlc())
                                return -1;
-                       }
                }
                val += incr;
        }
@@ -967,7 +953,6 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
                        !iteration_limit || iteration < iteration_limit;
                        iteration++) {
                if (ctrlc()) {
-                       putc('\n');
                        errs = -1UL;
                        break;
                }
@@ -981,7 +966,8 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
        }
 
        if (errs == -1UL) {
-               /* Memory test was aborted */
+               /* Memory test was aborted - write a newline to finish off */
+               putc('\n');
                ret = 1;
        } else {
                printf("Tested %d iteration(s) with %lu errors.\n",