From patchwork Mon Jun 24 22:36:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 253983 X-Patchwork-Delegate: jagannadh.teki@gmail.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 4BD072C0084 for ; Tue, 25 Jun 2013 08:37:50 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 874674A036; Tue, 25 Jun 2013 00:37:45 +0200 (CEST) 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 OdsLQ+FdW3bD; Tue, 25 Jun 2013 00:37:45 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BE96D4A027; Tue, 25 Jun 2013 00:37:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E1F2B4A037 for ; Tue, 25 Jun 2013 00:37:23 +0200 (CEST) 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 Pve7gAeGVLCN for ; Tue, 25 Jun 2013 00:37:18 +0200 (CEST) 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-qc0-f202.google.com (mail-qc0-f202.google.com [209.85.216.202]) by theia.denx.de (Postfix) with ESMTPS id 43F884A027 for ; Tue, 25 Jun 2013 00:37:12 +0200 (CEST) Received: by mail-qc0-f202.google.com with SMTP id z1so1321316qcx.1 for ; Mon, 24 Jun 2013 15:37:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=fx6zY/rX+MGsuOLu8lXu7/Wpu5n9lxTa3VDOB8P4+94=; b=Ppa6rdiWws7BhpjYCGlthqCpxbCKl+ViIQZv4hEpSVjPq+rEzSE04QsjZew7UVn+3K pTzjycZ1XJY9qU99ZUgsGZTbDCYnN6s/TpBOEbCZ+ypi6/5bkNt3Ha93P5OgssgQunHB kSulZ7PdNvoU0r3j/SbP9isBPiXYoywlyejNexJIP3w9Aqz93b6VVT7kSSEsIVm8Uoqi koJHvECP5gp1J9RXZBBnCtk7wBvdREAnsEhWiTJPaleuZnnitxB1Dqz0ZQCHT+lgr/OR im1Jl2j7euPVQ3Y6H3Z81p0asbjk9sD4nY+m7209b9vgJZL7Glvqs6GeJvjjqERamarr L5Qg== X-Received: by 10.236.15.73 with SMTP id e49mr14735327yhe.15.1372113431059; Mon, 24 Jun 2013 15:37:11 -0700 (PDT) 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 x33si10101672yhj.0.2013.06.24.15.37.11 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2013 15:37:11 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id D299D5A41EE; Mon, 24 Jun 2013 15:37:10 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 85A821608FB; Mon, 24 Jun 2013 15:37:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 24 Jun 2013 15:36:25 -0700 Message-Id: <1372113389-9415-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1372113389-9415-1-git-send-email-sjg@chromium.org> References: <1372113389-9415-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQkJNbyYJ7NaaPv1F6CjRWSEaZL+PKm0VppKF7ZGcUhYnXfYMgasnOgojqBZ7jluNQF2M3IXIEKABNlLOvfdBJz8SPqJmmWe3/eBaXUI9Or35p96QmjYjPNmL8HHxH1pcya4hoiKOsiG+26vm67eYEppLsO+SetV5rTHZIg+XQsSDfCtYSQ4FwxZQK5ZidWVCT3bri3K Cc: u-boot-review@google.com, Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH v4 2/6] sandbox: spi: Adjust 'sf test' to work on sandbox 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 Add map_sysmem() calls so that this test works correctly on sandbox. Signed-off-by: Simon Glass --- Changes in v4: - Add new patch to make 'sf test' work on sandbox Changes in v3: None Changes in v2: None common/cmd_sf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 19b0dc9..55a1c52 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -345,7 +345,8 @@ static void show_time(struct test_info *test, int stage) int bps; /* Bits per second */ speed = (long long)test->bytes * 1000; - do_div(speed, test->time_ms[stage] * 1024); + if (test->time_ms[stage]) + do_div(speed, test->time_ms[stage] * 1024); bps = speed * 8; printf("%d %s: %d ticks, %d KiB/s %d.%03d Mbps\n", stage, @@ -433,11 +434,13 @@ static int do_spi_flash_test(int argc, char * const argv[]) { unsigned long offset; unsigned long len; - uint8_t *buf = (uint8_t *)CONFIG_SYS_TEXT_BASE; + uint8_t *buf, *from; char *endp; uint8_t *vbuf; int ret; + if (argc < 3) + return -1; offset = simple_strtoul(argv[1], &endp, 16); if (*argv[1] == 0 || *endp != 0) return -1; @@ -447,17 +450,18 @@ static int do_spi_flash_test(int argc, char * const argv[]) vbuf = malloc(len); if (!vbuf) { - printf("Cannot allocate memory\n"); + printf("Cannot allocate memory (%lu bytes)\n", len); return 1; } buf = malloc(len); if (!buf) { free(vbuf); - printf("Cannot allocate memory\n"); + printf("Cannot allocate memory (%lu bytes)\n", len); return 1; } - memcpy(buf, (char *)CONFIG_SYS_TEXT_BASE, len); + from = map_sysmem(CONFIG_SYS_TEXT_BASE, 0); + memcpy(buf, from, len); ret = spi_flash_test(flash, buf, len, offset, vbuf); free(vbuf); free(buf);