From patchwork Wed Jan 7 03:39:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42803 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78EB42062F for ; Wed, 7 Jan 2015 03:41:18 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf249526lbv.5 for ; Tue, 06 Jan 2015 19:41:17 -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=bQC8FTS8FDWErMX2UibBfxV3R0tnFllt+dcrfmPHbFA=; b=OgpljH/WwfM4K8GvXQLkgJEjQN0dGhbnFEtXx/rtUByaNHRnvWxdTKKspHsauaYdnC wUiiCtKwNWqHg1f6qXUN3Tst7nS8jnPq2i11aPcD6onENNWs+SpPKoc9DBJ1UpX+HDuI z32NFlbmZBEqT0TvqP1iDRIt8V976yy9Zj1G3ITQieOu7U94spcj2a+tYNBcYNd9q3q7 ae+jQ/kfb7POG9KGxpt7H3kY3AJf3E6G/YCkboisDazc0sPzI+r5tj4vFT68TeDSe0YX BhNoeKiLCB7MtLNvmYYAKhlfiEOOe2dyZc4Dopd3azeSu2jgpIcOMnh51YRqlLD1wk/I eVtQ== X-Gm-Message-State: ALoCoQk+IzaqlJ1zB/LqvS5Ozhd8bwqqZeU60iWXO+1CR3XQISLRuRWwD1t0T/dA7mZ4ln074iRi X-Received: by 10.180.76.40 with SMTP id h8mr2624725wiw.3.1420602077108; Tue, 06 Jan 2015 19:41:17 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.229 with SMTP id v5ls113794lav.11.gmail; Tue, 06 Jan 2015 19:41:16 -0800 (PST) X-Received: by 10.152.121.100 with SMTP id lj4mr851037lab.58.1420602076843; Tue, 06 Jan 2015 19:41:16 -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 ay3si543282lbc.17.2015.01.06.19.41.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Jan 2015 19:41:16 -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 ms9so1207623lab.10 for ; Tue, 06 Jan 2015 19:41:16 -0800 (PST) X-Received: by 10.112.125.41 with SMTP id mn9mr834278lbb.80.1420602076567; Tue, 06 Jan 2015 19:41:16 -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.9.200 with SMTP id c8csp1355641lbb; Tue, 6 Jan 2015 19:41:15 -0800 (PST) X-Received: by 10.66.159.42 with SMTP id wz10mr1535168pab.8.1420602074561; Tue, 06 Jan 2015 19:41:14 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ot1si438366pdb.239.2015.01.06.19.41.13; Tue, 06 Jan 2015 19:41:14 -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 S1757167AbbAGDlB (ORCPT + 27 others); Tue, 6 Jan 2015 22:41:01 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:43469 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757099AbbAGDk6 (ORCPT ); Tue, 6 Jan 2015 22:40:58 -0500 Received: by mail-pd0-f174.google.com with SMTP id fp1so1925471pdb.5 for ; Tue, 06 Jan 2015 19:40:57 -0800 (PST) X-Received: by 10.70.128.131 with SMTP id no3mr1493516pdb.18.1420602057425; Tue, 06 Jan 2015 19:40:57 -0800 (PST) Received: from chunyanzhangubtpc.spreadtrum.com ([203.160.240.81]) by mx.google.com with ESMTPSA id pf10sm261320pbc.82.2015.01.06.19.40.54 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jan 2015 19:40:56 -0800 (PST) From: Chunyan Zhang To: samuel@sortiz.org Cc: arnd@linaro.org, zhang.lyra@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] driver/net/irda: Replace timeval with ktime_t in irda-usb Date: Wed, 7 Jan 2015 11:39:35 +0800 Message-Id: <1420601978-15866-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1420601978-15866-1-git-send-email-zhang.chunyan@linaro.org> References: <1420601978-15866-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. So, I use ktime_t instead of all uses of timeval. 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 use ktime_us_delta to get the elapsed time, and in this way it no longer needs to check for the overflow, because ktime_us_delta returns time difference of microsecond. Signed-off-by: Chunyan Zhang --- drivers/net/irda/irda-usb.c | 11 +++-------- drivers/net/irda/irda-usb.h | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 48b2f9a..be86840 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -495,18 +495,13 @@ static netdev_tx_t irda_usb_hard_xmit(struct sk_buff *skb, mtt = irda_get_mtt(skb); if (mtt) { int diff; - do_gettimeofday(&self->now); - diff = self->now.tv_usec - self->stamp.tv_usec; + self->now = ktime_get(); + diff = ktime_us_delta(self->now, self->stamp); #ifdef IU_USB_MIN_RTT /* Factor in USB delays -> Get rid of udelay() that * would be lost in the noise - Jean II */ diff += IU_USB_MIN_RTT; #endif /* IU_USB_MIN_RTT */ - /* If the usec counter did wraparound, the diff will - * go negative (tv_usec is a long), so we need to - * correct it by one second. Jean II */ - if (diff < 0) - diff += 1000000; /* Check if the mtt is larger than the time we have * already used by all the protocol processing @@ -869,7 +864,7 @@ static void irda_usb_receive(struct urb *urb) * reduce the min turn time a bit since we will know * how much time we have used for protocol processing */ - do_gettimeofday(&self->stamp); + self->stamp = ktime_get(); /* Check if we need to copy the data to a new skb or not. * For most frames, we use ZeroCopy and pass the already diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h index 58ddb52..8093216 100644 --- a/drivers/net/irda/irda-usb.h +++ b/drivers/net/irda/irda-usb.h @@ -29,7 +29,7 @@ * *****************************************************************************/ -#include +#include #include #include /* struct irlap_cb */ @@ -157,8 +157,8 @@ struct irda_usb_cb { char *speed_buff; /* Buffer for speed changes */ char *tx_buff; - struct timeval stamp; - struct timeval now; + ktime_t stamp; + ktime_t now; spinlock_t lock; /* For serializing Tx operations */