Patchwork [U-Boot,09/20] Bring mtest putc() into common code

login
register
mail settings
Submitter Simon Glass
Date Dec. 26, 2012, 6:57 p.m.
Message ID <1356548233-5570-10-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/208195/
State Superseded, archived
Delegated to: Simon Glass
Headers show

Comments

Simon Glass - Dec. 26, 2012, 6:57 p.m.
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 |   32 +++++++++-----------------------
 1 files changed, 9 insertions(+), 23 deletions(-)
Simon Glass - Feb. 15, 2013, 11:53 p.m.
On Wed, Dec 26, 2012 at 10:57 AM, Simon Glass <sjg@chromium.org> wrote:
> 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>

Applied to x86/master.

> ---
>  common/cmd_mem.c |   32 +++++++++-----------------------
>  1 files changed, 9 insertions(+), 23 deletions(-)

Patch

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 648f93b..a2f6cda 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -679,10 +679,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;
@@ -692,10 +690,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;
-				}
 			}
 		}
 	}
@@ -760,10 +756,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;
@@ -783,10 +777,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;
@@ -825,10 +817,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;
@@ -847,10 +837,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;
 	}
@@ -902,10 +890,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;
 	}
@@ -962,7 +948,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;
 		}
@@ -976,7 +961,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",