summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-27 09:09:09 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-04 08:03:04 +0100
commit8f130c738e6a28f8427a6b9bff8830f216aaa7e4 (patch)
tree3a12502060ed1bbe411b1999ebeeb52e2e19b527 /common
parentb9f9eef7220612c0ff3077ce8a39d420b348b141 (diff)
downloadbarebox-8f130c738e6a28f8427a6b9bff8830f216aaa7e4.tar.gz
memtest: move ctrlc check / progress showing into separate function
To make the actual test a bit better visible in the code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/memtest.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/common/memtest.c b/common/memtest.c
index 9bd9025..d0a0571 100644
--- a/common/memtest.c
+++ b/common/memtest.c
@@ -331,9 +331,24 @@ int mem_test_bus_integrity(resource_size_t _start,
return 0;
}
+static int update_progress(resource_size_t offset)
+{
+ /* Only check every 4k to reduce overhead */
+ if (offset & (SZ_4K - 1))
+ return 0;
+
+ if (ctrlc())
+ return -EINTR;
+
+ show_progress(offset);
+
+ return 0;
+}
+
int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end)
{
volatile resource_size_t *start, num_words, offset, temp, anti_pattern;
+ int ret;
_start = ALIGN(_start, sizeof(resource_size_t));
_end = ALIGN_DOWN(_end, sizeof(resource_size_t)) - 1;
@@ -362,22 +377,17 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end)
/* Fill memory with a known pattern */
for (offset = 0; offset < num_words; offset++) {
- /* Every 4K we update the progressbar */
- if (!(offset & (SZ_4K - 1))) {
- if (ctrlc())
- return -EINTR;
- show_progress(offset);
- }
+ ret = update_progress(offset);
+ if (ret)
+ return ret;
start[offset] = offset + 1;
}
/* Check each location and invert it for the second pass */
for (offset = 0; offset < num_words; offset++) {
- if (!(offset & (SZ_4K - 1))) {
- if (ctrlc())
- return -EINTR;
- show_progress(num_words + offset);
- }
+ ret = update_progress(num_words + offset);
+ if (ret)
+ return ret;
temp = start[offset];
if (temp != (offset + 1)) {
@@ -394,11 +404,9 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end)
/* Check each location for the inverted pattern and zero it */
for (offset = 0; offset < num_words; offset++) {
- if (!(offset & (SZ_4K - 1))) {
- if (ctrlc())
- return -EINTR;
- show_progress(2 * num_words + offset);
- }
+ ret = update_progress(2 * num_words + offset);
+ if (ret)
+ return ret;
anti_pattern = ~(offset + 1);
temp = start[offset];