From patchwork Thu Dec 18 11:52:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42428 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8CC5926C8B for ; Thu, 18 Dec 2014 11:53:30 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf590659wiv.1 for ; Thu, 18 Dec 2014 03:53: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: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=Hft0HTlDbvym2QVnNXo/bUaYR1x3AFV9NX1MSdCRK+Y=; b=RvnKrARJBMXYoObqrlAIJwxMk0NNSVK50Bxjo/gngyOepakteD5kLSLLX4XMYKYqA3 FYr9EhHiAPCaAUwpoRQrfCISDH+/nGNfUoHwgCOb7EeNTNsRZ+tTioIYORwVxWAFiW7l lMOnqp9QnHtYEuclBUQx8HCSrlLxFFDaUnyoNyZU7E0nAc76H+O/M3dRaAJleC3AJSH+ 9+jSMbTKrgeuOG2DhQatTktiO5Q4cIPr+H5AqAiy1qCtNYvxUp5Q3qkf+gIm5sB/V/83 tLTdVj3Z2tlrS0ltQDzXug69aL08Zn2lQz1ra3Vgrha+T2usNBKzIWorCPf7eMPMWuSd RKlQ== X-Gm-Message-State: ALoCoQk2uyUA2y1rpf2lRSUrhKJ40DG0dFs1z76RerOOoMhr0AdNTRX0iVRRN+Mo8Su+rbixzhJ/ X-Received: by 10.112.138.234 with SMTP id qt10mr279566lbb.4.1418903609809; Thu, 18 Dec 2014 03:53:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.11.163 with SMTP id ej3ls1103285lad.94.gmail; Thu, 18 Dec 2014 03:53:29 -0800 (PST) X-Received: by 10.112.170.36 with SMTP id aj4mr1806687lbc.3.1418903609428; Thu, 18 Dec 2014 03:53:29 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id sj12si6700671lac.1.2014.12.18.03.53.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 03:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so832630lab.24 for ; Thu, 18 Dec 2014 03:53:29 -0800 (PST) X-Received: by 10.152.116.46 with SMTP id jt14mr1802878lab.59.1418903609278; Thu, 18 Dec 2014 03:53:29 -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 ru5csp1678458lbb; Thu, 18 Dec 2014 03:53:28 -0800 (PST) X-Received: by 10.68.105.130 with SMTP id gm2mr2441712pbb.15.1418903607262; Thu, 18 Dec 2014 03:53:27 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ox6si9659861pbb.180.2014.12.18.03.53.26; Thu, 18 Dec 2014 03:53:27 -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 S1752352AbaLRLxX (ORCPT + 27 others); Thu, 18 Dec 2014 06:53:23 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:35312 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752311AbaLRLxS (ORCPT ); Thu, 18 Dec 2014 06:53:18 -0500 Received: by mail-pd0-f173.google.com with SMTP id ft15so1292115pdb.4 for ; Thu, 18 Dec 2014 03:53:17 -0800 (PST) X-Received: by 10.68.129.6 with SMTP id ns6mr2494544pbb.137.1418903597754; Thu, 18 Dec 2014 03:53:17 -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.10 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Dec 2014 03:53:16 -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 3/3] media: rc: Replace timeval with ktime_t in imon.c Date: Thu, 18 Dec 2014 19:52:02 +0800 Message-Id: <1418903522-19137-4-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.215.51 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 all uses of timeval in imon.c 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 Acked-by: Mauro Carvalho Chehab --- drivers/media/rc/imon.c | 49 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index b8837dd..a1e91d5 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #define MOD_AUTHOR "Jarod Wilson " @@ -1158,29 +1158,6 @@ out: return retval; } -static inline int tv2int(const struct timeval *a, const struct timeval *b) -{ - int usecs = 0; - int sec = 0; - - if (b->tv_usec > a->tv_usec) { - usecs = 1000000; - sec--; - } - - usecs += a->tv_usec - b->tv_usec; - - sec += a->tv_sec - b->tv_sec; - sec *= 1000; - usecs /= 1000; - sec += usecs; - - if (sec < 0) - sec = 1000; - - return sec; -} - /** * The directional pad behaves a bit differently, depending on whether this is * one of the older ffdc devices or a newer device. Newer devices appear to @@ -1191,16 +1168,16 @@ static inline int tv2int(const struct timeval *a, const struct timeval *b) */ static int stabilize(int a, int b, u16 timeout, u16 threshold) { - struct timeval ct; - static struct timeval prev_time = {0, 0}; - static struct timeval hit_time = {0, 0}; + ktime_t ct; + static ktime_t prev_time; + static ktime_t hit_time; static int x, y, prev_result, hits; int result = 0; - int msec, msec_hit; + long msec, msec_hit; - do_gettimeofday(&ct); - msec = tv2int(&ct, &prev_time); - msec_hit = tv2int(&ct, &hit_time); + ct = ktime_get(); + msec = ktime_ms_delta(ct, prev_time); + msec_hit = ktime_ms_delta(ct, hit_time); if (msec > 100) { x = 0; @@ -1596,9 +1573,9 @@ static void imon_incoming_packet(struct imon_context *ictx, int i; u64 scancode; int press_type = 0; - int msec; - struct timeval t; - static struct timeval prev_time = { 0, 0 }; + long msec; + ktime_t t; + static ktime_t prev_time; u8 ktype; /* filter out junk data on the older 0xffdc imon devices */ @@ -1692,10 +1669,10 @@ static void imon_incoming_packet(struct imon_context *ictx, /* Only panel type events left to process now */ spin_lock_irqsave(&ictx->kc_lock, flags); - do_gettimeofday(&t); + t = ktime_get(); /* KEY_MUTE repeats from knob need to be suppressed */ if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { - msec = tv2int(&t, &prev_time); + msec = ktime_ms_delta(t, prev_time); if (msec < ictx->idev->rep[REP_DELAY]) { spin_unlock_irqrestore(&ictx->kc_lock, flags); return;