From patchwork Thu Dec 18 11:52:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42427 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E4E326C8B for ; Thu, 18 Dec 2014 11:53:24 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf640347lab.11 for ; Thu, 18 Dec 2014 03:53:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=iATuNDl4LE9UaI0WYo2Fb643DthaHKA4xKuJ3AZPd7Y=; b=KZHkRplUW2Kk1u7o9Qw0s3vXMx4NGORtamUAGH2tzk8tgOCeSApNIeXKAjjNJUIibZ gcVqF5x+hQa7LWHjvNIKeR6LT6Jvqqqjc4W8GakQIj/QKxbERGOAYfVxfflYEkd+3dKo EYh0vuLU8ftME+0UirSUPnFLF2XjmANfj8fz6p6OXndXhm+wBopCwKc73SQjwQO/pzeh IF1zxfX7fAuoJ8riCaPABDZLwZ1hyixcFnTqb7QhR+Dtgap7ujGETM9O2mvOWUdCbZN2 ewc7lI90CL7YmObt1NbfThASfk1blMAznHmUIai70sJwcilndE8mJuxe4lHa9tmVtAp9 3YJQ== X-Gm-Message-State: ALoCoQlYkurdfMqyWofs+FI6O/uj3oVPSip1dMaTAPsdHGR9TI+dcHypbeB0meOAuPvO/a2y4tUw X-Received: by 10.180.99.227 with SMTP id et3mr77128wib.3.1418903603036; Thu, 18 Dec 2014 03:53:23 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.38 with SMTP id ld6ls1209428lac.50.gmail; Thu, 18 Dec 2014 03:53:22 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr1770452laz.71.1418903602748; Thu, 18 Dec 2014 03:53:22 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id dd4si6688804lad.13.2014.12.18.03.53.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 03:53:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id z12so803026lbi.32 for ; Thu, 18 Dec 2014 03:53:22 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr1835014lbb.32.1418903602637; Thu, 18 Dec 2014 03:53:22 -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.142.69 with SMTP id ru5csp1678433lbb; Thu, 18 Dec 2014 03:53:21 -0800 (PST) X-Received: by 10.70.47.195 with SMTP id f3mr2661924pdn.156.1418903600655; Thu, 18 Dec 2014 03:53:20 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ht9si9642281pad.207.2014.12.18.03.53.19; Thu, 18 Dec 2014 03:53:20 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbaLRLxM (ORCPT + 27 others); Thu, 18 Dec 2014 06:53:12 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:65461 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752175AbaLRLxI (ORCPT ); Thu, 18 Dec 2014 06:53:08 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so1296544pad.9 for ; Thu, 18 Dec 2014 03:53:08 -0800 (PST) X-Received: by 10.66.217.228 with SMTP id pb4mr2744762pac.116.1418903587858; Thu, 18 Dec 2014 03:53:07 -0800 (PST) Received: from chunyanzhangubtpc.spreadtrum.com ([203.160.240.81]) by mx.google.com with ESMTPSA id pb6sm6661708pbb.13.2014.12.18.03.53.00 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Dec 2014 03:53:06 -0800 (PST) From: Chunyan Zhang To: m.chehab@samsung.com, david@hardeman.nu, uli-lirc@uli-eckhardt.de, hans.verkuil@cisco.com, julia.lawall@lip6.fr, himangi774@gmail.com, khoroshilov@ispras.ru, joe@perches.com, dborkman@redhat.com, john.stultz@linaro.org, tglx@linutronix.de, davem@davemloft.net, dwmw2@infradead.org, computersforpeace@gmail.com, arnd@linaro.org Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, zhang.lyra@gmail.com Subject: [PATCH 2/3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c Date: Thu, 18 Dec 2014 19:52:01 +0800 Message-Id: <1418903522-19137-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418903522-19137-1-git-send-email-zhang.chunyan@linaro.org> References: <1418903522-19137-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.217.173 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. This patch will use a new function 'ktime_ms_delta' which is introduced in 1/3 of this patch-set to get the millisecond time difference. Signed-off-by: Chunyan Zhang Reviewed-by: Arnd Bergmann --- 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..87a6e25 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_ms_delta(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..7e77ed4 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_ms_delta(finish, start); pr_info("%08u erase cycles done, took %lu " "milliseconds (%lu seconds)\n", erase_cycles, ms, ms / 1000);