mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 04/10] common/memtest.c: Distil common error reporting code
Date: Wed, 13 May 2015 19:54:21 -0700	[thread overview]
Message-ID: <1431572067-4038-4-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1431572067-4038-1-git-send-email-andrew.smirnov@gmail.com>

Move all of the common code for error message output into a new
function mem_test_report_failure() and convert the rest of the code to
use it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/memtest.c | 53 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/common/memtest.c b/common/memtest.c
index 57e2ad9..d8d1154 100644
--- a/common/memtest.c
+++ b/common/memtest.c
@@ -28,6 +28,17 @@
 #include <errno.h>
 #include <memtest.h>

+static void mem_test_report_failure(const char *failure_description,
+				    resource_size_t expected_value,
+				    resource_size_t actual_value,
+				    volatile resource_size_t *address)
+{
+	printf("FAILURE (%s): "
+	       "expected 0x%08x, actual 0x%08x at address 0x%08x.\n",
+	       failure_description, expected_value, actual_value,
+	       (resource_size_t)address);
+}
+
 int mem_test_bus_integrity(resource_size_t _start,
 			   resource_size_t _end)
 {
@@ -87,9 +98,8 @@ int mem_test_bus_integrity(resource_size_t _start,
 			*dummy = ~val;
 			readback = *start;
 			if (readback != val) {
-				printf("FAILURE (data line): "
-					"expected 0x%08x, actual 0x%08x at address 0x%08x.\n",
-					val, readback, (resource_size_t)start);
+				mem_test_report_failure("data line",
+							val, readback, start);
 				return -EIO;
 			}

@@ -97,10 +107,8 @@ int mem_test_bus_integrity(resource_size_t _start,
 			*dummy = val;
 			readback = *start;
 			if (readback != ~val) {
-				printf("FAILURE (data line): "
-					"Is 0x%08x, should be 0x%08x at address 0x%08x.\n",
-					readback,
-					~val, (resource_size_t)start);
+				mem_test_report_failure("data line",
+							~val, readback, start);
 				return -EIO;
 			}
 		}
@@ -174,11 +182,8 @@ int mem_test_bus_integrity(resource_size_t _start,
 	for (offset = 1; offset <= num_words; offset <<= 1) {
 		temp = start[offset];
 		if (temp != pattern) {
-			printf("FAILURE: Address bit "
-					"stuck high @ 0x%08x:"
-					" expected 0x%08x, actual 0x%08x.\n",
-					(resource_size_t)&start[offset],
-					pattern, temp);
+			mem_test_report_failure("address bit stuck high",
+						pattern, temp, &start[offset]);
 			return -EIO;
 		}
 	}
@@ -203,11 +208,9 @@ int mem_test_bus_integrity(resource_size_t _start,

 			if ((temp != pattern) &&
 					(offset != offset2)) {
-				printf("FAILURE: Address bit stuck"
-						" low or shorted @"
-						" 0x%08x: expected 0x%08x, actual 0x%08x.\n",
-						(resource_size_t)&start[offset],
-						pattern, temp);
+				mem_test_report_failure(
+					"address bit stuck low or shorted",
+					pattern, temp, &start[offset]);
 				return -EIO;
 			}
 		}
@@ -278,10 +281,10 @@ int mem_test_dram(resource_size_t _start,

 		temp = start[offset];
 		if (temp != (offset + 1)) {
-			printf("\nFAILURE (read/write) @ 0x%08x:"
-					" expected 0x%08x, actual 0x%08x.\n",
-					(resource_size_t)&start[offset],
-					(offset + 1), temp);
+			printf("\n");
+			mem_test_report_failure("read/write",
+						(offset + 1),
+						temp, &start[offset]);
 			return -EIO;
 		}

@@ -306,10 +309,10 @@ int mem_test_dram(resource_size_t _start,
 		temp = start[offset];

 		if (temp != anti_pattern) {
-			printf("\nFAILURE (read/write): @ 0x%08x:"
-					" expected 0x%08x, actual 0x%08x.\n",
-					(resource_size_t)&start[offset],
-					anti_pattern, temp);
+			printf("\n");
+			mem_test_report_failure("read/write",
+						anti_pattern,
+						temp, &start[offset]);
 			return -EIO;
 		}

--
2.1.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-05-14  2:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14  2:54 [PATCH 01/10] common/memtest.c: Fix incorrect array boundary check Andrey Smirnov
2015-05-14  2:54 ` [PATCH 02/10] common/memtest.c: Do not omit offset of 0 from tests Andrey Smirnov
2015-05-14  2:54 ` [PATCH 03/10] common/memtest.c: Refactor mem_test() into three surbroutines Andrey Smirnov
2015-05-14  2:54 ` Andrey Smirnov [this message]
2015-05-14  2:54 ` [PATCH 05/10] serial: i.MX: Write settings to a correct register Andrey Smirnov
2015-05-14  2:54 ` [PATCH 06/10] common: pbl: Allow boards to override hang() Andrey Smirnov
2015-05-15  5:25   ` Sascha Hauer
2015-05-23 18:13     ` Andrey Smirnov
2015-05-14  2:54 ` [PATCH 07/10] debug_ll: i.MX: Add support for input to DEBUG_LL Andrey Smirnov
2015-05-14  2:54 ` [PATCH 08/10] i.MX51: babbage: Add UART RXD pin configuration Andrey Smirnov
2015-05-14  2:54 ` [PATCH 09/10] pbl: Implement ctrlc() using getc_ll() Andrey Smirnov
2015-05-14  2:54 ` [PATCH 10/10] ARM: pbl: Add an option to validate DRAM Andrey Smirnov
2015-05-19  7:06   ` Sascha Hauer
2015-05-23 18:48     ` Andrey Smirnov
2015-05-23 20:44       ` Alexander Aring
2015-05-24 18:39         ` Andrey Smirnov
2015-05-26  6:57       ` Sascha Hauer
2015-06-01 13:09         ` Andrey Smirnov
2015-06-03  8:10           ` Sascha Hauer
2015-05-15  5:33 ` [PATCH 01/10] common/memtest.c: Fix incorrect array boundary check Sascha Hauer
2015-05-23 18:20   ` Andrey Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431572067-4038-4-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox