From patchwork Wed Dec 26 18:57:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 208195 X-Patchwork-Delegate: sjg@chromium.org 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 8E5612C00BD for ; Thu, 27 Dec 2012 06:00:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E5B74A0F9; Wed, 26 Dec 2012 20:00:03 +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 ktZzQ3SDJpO2; Wed, 26 Dec 2012 20:00:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 285D74A0FD; Wed, 26 Dec 2012 19:58:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51CA64A052 for ; Wed, 26 Dec 2012 19:57:47 +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 XOdr5Fpk+VTX for ; Wed, 26 Dec 2012 19:57:42 +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-ye0-f201.google.com (mail-ye0-f201.google.com [209.85.213.201]) by theia.denx.de (Postfix) with ESMTPS id B93F44A092 for ; Wed, 26 Dec 2012 19:57:33 +0100 (CET) Received: by mail-ye0-f201.google.com with SMTP id r11so927564yen.4 for ; Wed, 26 Dec 2012 10:57:31 -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=q5YXnWP1Hdf8E740/utshmcZHplKCbJINJje5MGRhow=; b=QxTilCsCggyCcF5AKUZWqZo8VBwofeyrS1iF8vowqG96jyZ/SC/dK+gEJ8Jcq7pDZe rfOQ0x6l/ANWaxNZ5fEvro4VVR1LZxGypKTljvgiTthZlDbfssaRAIUwDuqgTsSjYbOu PHHkZ4DZEcLrte03bEY0zwYbQmonjKmXwxjpIRy0sN+fb4Eu7SQBcZZO7omrhCfjOmlP 5bJSvC3AxDzNUQaVeVUsrS5RRiShbhwmV2uRFXHobSMtLnTonoL11eGBCXagom+84gSi zX6CuTaasvV1OgLcGTN9CYiYmir9j12FVE3/bnkxZmMaPnlFK0JO7oUOgAKyPpvVwtKd tQuQ== X-Received: by 10.101.17.17 with SMTP id u17mr3443536ani.4.1356548251370; Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id u20si1205325anj.3.2012.12.26.10.57.31 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 44A10820055; Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id EB67A160D91; Wed, 26 Dec 2012 10:57:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 26 Dec 2012 10:57:02 -0800 Message-Id: <1356548233-5570-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1356548233-5570-1-git-send-email-sjg@chromium.org> References: <1356548233-5570-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQl6CEZEKiPN/MLLkEB4hUTvIx5VwUDDoY1GDjVmPufuB2i5LaObVOHimkZkVri9x5LO06ETOKsjyS9Rb4u4wpMMUDM14yDeLe07QO/EFfIbTXRUqE19ZwUFot1GIMXkUZp+DEDoRasBmRmp0RUMTs0Ie+tmNATHmfVidk0LLg4ipW+kbjTuWS+xQEO31RJ4/ctkFfzb Cc: Tom Rini , Joe Hershberger , Kumar Gala Subject: [U-Boot] [PATCH 09/20] 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 --- common/cmd_mem.c | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-) 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",