From patchwork Mon Feb 25 03:33:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222828 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4286D2C02AF for ; Mon, 25 Feb 2013 14:35:36 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CD374A258; Mon, 25 Feb 2013 04:35:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d4NnEHvMtpVd; Mon, 25 Feb 2013 04:35:21 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 038464A161; Mon, 25 Feb 2013 04:34:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 378044A132 for ; Mon, 25 Feb 2013 04:34:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YMyOFkbXwC2K for ; Mon, 25 Feb 2013 04:34:04 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vb0-f74.google.com (mail-vb0-f74.google.com [209.85.212.74]) by theia.denx.de (Postfix) with ESMTPS id F27784A113 for ; Mon, 25 Feb 2013 04:33:55 +0100 (CET) Received: by mail-vb0-f74.google.com with SMTP id r6so254743vbi.1 for ; Sun, 24 Feb 2013 19:33:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=EKDvO5oKe2ESNUiiFQxeBNV/quLJOJyWE0DLLvjiky4=; b=J2+WDXJMEjYAxHbOlHM25WtwKO/carLAA6v9lev1ilB9ncwcwla/fUVquqnkgt5R3d 17JIhFykX/9wMp7kBENVErQrZ+KJNPtqNJvKzHLjARU7ZCfKprD7S3MLFgV6OI7GXNN3 Q1sCAUD8u0Rf2joU5X9BcCHm6DHgZ3WBdfm+OEO/UBj/aYzWdwNUXK/FEDFrY3q4tH6H ALuqFJ3h8OVQvsxh1/MD0XovwqjEK+m8c7/MDHuiPnsi0fEEfe7DHcpdBNJCmgQ6AOyI y5OGV48wtD9zjUWcUkSnQCu6F5mH2ylxCEhsih5Z3hpnwPMiLo6MdpCLOJ3KHnq0gDQZ qBnw== X-Received: by 10.236.130.141 with SMTP id k13mr6117361yhi.19.1361763234426; Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u21si809652yhj.0.2013.02.24.19.33.54 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 4912E5A42E0; Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 2A7DF160537; Sun, 24 Feb 2013 19:33:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 24 Feb 2013 19:33:19 -0800 Message-Id: <1361763213-31183-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361763213-31183-1-git-send-email-sjg@chromium.org> References: <1361763213-31183-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQngXtxddL/X62ZptsL5aGqo7ozY535BmYiVjJIJL0Sqrl/aZABFTXTSllw26OKC32yYJlWqvlGaRQtmvA2HkMfTFO5hyoxgiZ4+5mK5GTGjv9TzfK+5gdTvMO1RbA7dZtap9zTO4N6iKwCG/vanpPWBWbz22oRKbl5/YXPM/LQW9MGhidOFplrpRDXN1A28sBsBo8hY Cc: Tom Rini Subject: [U-Boot] [PATCH v3 09/22] Bring mtest putc() into common code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- Changes in v3: None Changes in v2: None common/cmd_mem.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 5235bfe..f5dd56d 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -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",