From patchwork Tue Dec 2 11:22:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 41805 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4F16920672 for ; Tue, 2 Dec 2014 11:25:08 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf8080141wid.3 for ; Tue, 02 Dec 2014 03:25:07 -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:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=+pwxyPgR5u8yB2IuzUpUcqwXHQLBpl5R6VSFg1OysfY=; b=EWDOlaJsTUONObMSqlnlcQDDd8bZKkna5jtIA9B6faX3jWItMTp1Hj6aCK/QZBQ5y4 LUjkYHezxMMtHhtLY/EoiVI+8c4SVapU1/HbbdwV6IycSjMlIS1G6oG9zmaS7imFEWGD 3cVkPlebvMk+xl7OyT3yoIfMfWXXdoFbDqixQWbU1/CKmOl5CpwK7nxX56RMpnEL4j1J AhsDZ4HILrxIXaabpliK3lPK3sULla1p3hQk/m2tgUzq0q0WAFeJ6LsrWErLO0SaFO4X zfE2REjRaQ0EOFKHF8UTCY2meKdXTjugTFURfir2qz9lOdlbfjkSc/wQzK9ealCj0x4C gkDg== X-Gm-Message-State: ALoCoQn8w9+xKW00NJ6V0WcyPSz/0glj/jZDynWrnM+QJJXOEiUK15jLC7kcl3MnY4ee28vKXQrX X-Received: by 10.180.8.9 with SMTP id n9mr753836wia.6.1417519507629; Tue, 02 Dec 2014 03:25:07 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls25629lat.20.gmail; Tue, 02 Dec 2014 03:25:07 -0800 (PST) X-Received: by 10.112.254.162 with SMTP id aj2mr62367803lbd.70.1417519507467; Tue, 02 Dec 2014 03:25:07 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id c6si20105598laa.50.2014.12.02.03.25.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 03:25:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so5500365lam.5 for ; Tue, 02 Dec 2014 03:25:07 -0800 (PST) X-Received: by 10.152.2.165 with SMTP id 5mr13794906lav.40.1417519507179; Tue, 02 Dec 2014 03:25:07 -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 ew9csp462887lbc; Tue, 2 Dec 2014 03:25:06 -0800 (PST) X-Received: by 10.70.129.48 with SMTP id nt16mr55918161pdb.113.1417519505379; Tue, 02 Dec 2014 03:25:05 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ez4si33068942pbb.37.2014.12.02.03.25.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2014 03:25:05 -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 1XvlYG-00026B-Hm; Tue, 02 Dec 2014 11:23:28 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XvlYE-0001yd-Eq for linux-mtd@lists.infradead.org; Tue, 02 Dec 2014 11:23:26 +0000 Received: by mail-pa0-f42.google.com with SMTP id et14so13228542pad.15 for ; Tue, 02 Dec 2014 03:23:04 -0800 (PST) X-Received: by 10.68.215.67 with SMTP id og3mr4443760pbc.117.1417519384694; Tue, 02 Dec 2014 03:23:04 -0800 (PST) Received: from chunyanzhangubtpc.local.spreadtrum.com ([203.160.240.81]) by mx.google.com with ESMTPSA id tr8sm7307208pbc.30.2014.12.02.03.23.01 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Dec 2014 03:23:03 -0800 (PST) From: Chunyan Zhang To: dwmw2@infradead.org, computersforpeace@gmail.com Subject: [PATCH v2] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c Date: Tue, 2 Dec 2014 19:22:34 +0800 Message-Id: <1417519354-25794-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141202_032326_515165_CD1437DD X-CRM114-Status: GOOD ( 13.23 ) 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 [209.85.220.42 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.220.42 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@linaro.org 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: , MIME-Version: 1.0 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.46 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 the 64-bit one (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 Reviewed-by: Arnd Bergmann --- Changes since v1: - Add including in torturetest.c --- drivers/mtd/tests/speedtest.c | 10 +++++----- drivers/mtd/tests/torturetest.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5ee9f70..322925f 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -22,6 +22,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -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..96da5d5 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -26,6 +26,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -79,18 +80,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 +323,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);