From patchwork Fri Nov 28 11:05:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 41695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 185F125E46 for ; Fri, 28 Nov 2014 11:08:30 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf4141982wiw.4 for ; Fri, 28 Nov 2014 03:08:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:date:message-id :subject:from:to:cc:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=GVIyOiBKhSAPIwyoUKYQGjYE4VDchh/kZtJ67qT0tSQ=; b=OmIlhB8cj67BxAeKS9Ph29fUpGSR1ZQOeT1d4enN+MaAF7HKJc9JnXnbL7hJ+CsgmR G41gV1EGthNegzlutWtW7TR4fRep3+Rzj7V9IQssCUraUA0+scwehXgm4cA5eF+23qBK 1Oq+nNbKl2b8y0XwChlO4w3+tGT6ZgIbWFTbhl8HGnLE+xNPhkjhY5Ej2ovdpfgRbrVU ZNZb1wzbQctMKPvSRhm2WB4Bho7/OJmUzsJ3hUWIcKFr4fwBAaGxGlw4HFZwF95vbtqf uU4DeF+Jj1yrWiGnF87eigwdiUiHJs6hoIDCQGnkcQuH3Y0YGe1l1KnatMP6IMLj5XGe yEig== X-Gm-Message-State: ALoCoQnClhpofBIubhA9I1wj5Md8DxfRfpTSrzG6K9hPVQI542rS6cmXoVPvyq85B/gyCSAW5C82 X-Received: by 10.152.26.72 with SMTP id j8mr11967528lag.3.1417172909331; Fri, 28 Nov 2014 03:08:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.9 with SMTP id p9ls949885lag.80.gmail; Fri, 28 Nov 2014 03:08:28 -0800 (PST) X-Received: by 10.112.142.197 with SMTP id ry5mr43949823lbb.26.1417172908945; Fri, 28 Nov 2014 03:08:28 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id as7si9640374lbc.94.2014.11.28.03.08.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 03:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so5605669lam.35 for ; Fri, 28 Nov 2014 03:08:28 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr42710952lbo.32.1417172908805; Fri, 28 Nov 2014 03:08:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp70896lbc; Fri, 28 Nov 2014 03:08:27 -0800 (PST) X-Received: by 10.70.118.1 with SMTP id ki1mr72496295pdb.69.1417172907128; Fri, 28 Nov 2014 03:08:27 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fn7si15759903pad.65.2014.11.28.03.08.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Nov 2014 03:08:27 -0800 (PST) Received-SPF: none (google.com: linux-mtd-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XuJNB-0008NG-RU; Fri, 28 Nov 2014 11:06:01 +0000 Received: from mail-wg0-f46.google.com ([74.125.82.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XuJN8-00089z-P5 for linux-mtd@lists.infradead.org; Fri, 28 Nov 2014 11:05:59 +0000 Received: by mail-wg0-f46.google.com with SMTP id a1so305562wgh.5 for ; Fri, 28 Nov 2014 03:05:34 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.85.83 with SMTP id f19mr69543448wjz.20.1417172733934; Fri, 28 Nov 2014 03:05:33 -0800 (PST) Received: by 10.194.44.67 with HTTP; Fri, 28 Nov 2014 03:05:33 -0800 (PST) Date: Fri, 28 Nov 2014 19:05:33 +0800 Message-ID: Subject: [PATCH] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c From: Chunyan Zhang To: dwmw2@infradead.org, computersforpeace@gmail.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141128_030558_999048_9E1F7227 X-CRM114-Status: GOOD ( 12.06 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.46 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.46 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: john.stultz@linaro.org, linux-mtd@lists.infradead.org, Arnd Bergmann X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhang.chunyan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch changes the 32-bit time type (timeval) to 64-bit (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of timeval to define 'start' and 'finish' which are used to get the time for tow points. This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. Signed-off-by: Chunyan Zhang --- drivers/mtd/tests/speedtest.c | 10 +++++----- drivers/mtd/tests/torturetest.c | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) -- 1.7.9.5 diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5ee9f70..73e26d6 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "mtd_test.h" @@ -49,7 +50,7 @@ static int pgsize; static int ebcnt; static int pgcnt; static int goodebcnt; -static struct timeval start, finish; +static ktime_t start, finish; static int multiblock_erase(int ebnum, int blocks) { @@ -168,12 +169,12 @@ static int read_eraseblock_by_2pages(int ebnum) static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } static long calc_speed(void) @@ -181,8 +182,7 @@ static long calc_speed(void) uint64_t k; long ms; - ms = (finish.tv_sec - start.tv_sec) * 1000 + - (finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_to_ms(ktime_sub(finish, start)); if (ms == 0) return 0; k = goodebcnt * (mtd->erasesize / 1024) * 1000; diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c index eeab969..620fff6 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -79,18 +79,18 @@ static unsigned char *check_buf; static unsigned int erase_cycles; static int pgsize; -static struct timeval start, finish; +static ktime_t start, finish; static void report_corrupt(unsigned char *read, unsigned char *written); static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } /* @@ -322,8 +322,7 @@ static int __init tort_init(void) long ms; stop_timing(); - ms = (finish.tv_sec - start.tv_sec) * 1000 + - (finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_to_ms(ktime_sub(finish, start)); pr_info("%08u erase cycles done, took %lu " "milliseconds (%lu seconds)\n", erase_cycles, ms, ms / 1000);