From patchwork Wed Jan 7 03:39:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42802 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 598F82062F for ; Wed, 7 Jan 2015 03:41:17 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf253152lbv.1 for ; Tue, 06 Jan 2015 19:41:16 -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=HVW6aID7jIj+st3D0ETulJweJ3UJe5mhe2aY7D+r6dQ=; b=EgKh3SkJ+2HGAV5nQjJlYWKXtqtvYV1AxgbW1h+5RztPmJpO9R7lxn1UaGK6j/7/bW kGMjyRY7QUOQLOZs9ZG0lyMvfGwh9bUyKBvUfJXawacjtBfm2qcGkGYQPV5ybLFOy0jr otNvpwq7EjRt/ggSn2Fo4/fclwHFAVZ/1bW3Tp9uYUy4x4u6gm9NHgkCHQZsfKgM8o3S ZdSf+9QdcdcRxh0x+OZcr1zGLFARMkwtXyCLN2Bgx+artnltugKjcEsr8xBBemgv8BiP xz1nqN7gLUiBWFSJExD2wqZYXlTYKxkECu0766JwYsTzsl+Dqof/VYdSX80c/zNNzNG6 cAgQ== X-Gm-Message-State: ALoCoQk/R5qiKoZmf4jVYNTuio25ZIT+h7P2Jgf9NuEQpEQW+HBGt/BnP9GohTq/lkoVMqPv8uL7 X-Received: by 10.180.89.211 with SMTP id bq19mr2622845wib.4.1420602075988; Tue, 06 Jan 2015 19:41:15 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.226 with SMTP id kt2ls118074lac.52.gmail; Tue, 06 Jan 2015 19:41:15 -0800 (PST) X-Received: by 10.152.28.99 with SMTP id a3mr872829lah.18.1420602075592; Tue, 06 Jan 2015 19:41:15 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id e1si440830laa.119.2015.01.06.19.41.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Jan 2015 19:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so1249607lab.4 for ; Tue, 06 Jan 2015 19:41:15 -0800 (PST) X-Received: by 10.112.163.33 with SMTP id yf1mr839101lbb.56.1420602075506; Tue, 06 Jan 2015 19:41:15 -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 c8csp1355637lbb; Tue, 6 Jan 2015 19:41:14 -0800 (PST) X-Received: by 10.66.159.67 with SMTP id xa3mr1326627pab.13.1420602073591; Tue, 06 Jan 2015 19:41:13 -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.12; Tue, 06 Jan 2015 19:41:13 -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 S1757098AbbAGDk5 (ORCPT + 27 others); Tue, 6 Jan 2015 22:40:57 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:54003 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755988AbbAGDky (ORCPT ); Tue, 6 Jan 2015 22:40:54 -0500 Received: by mail-pa0-f44.google.com with SMTP id et14so2029975pad.3 for ; Tue, 06 Jan 2015 19:40:54 -0800 (PST) X-Received: by 10.68.132.2 with SMTP id oq2mr1232330pbb.45.1420602053954; Tue, 06 Jan 2015 19:40:53 -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.50 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jan 2015 19:40:53 -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 2/6] driver/net/irda: Replace timeval with ktime_t in ali-ircc Date: Wed, 7 Jan 2015 11:39:34 +0800 Message-Id: <1420601978-15866-3-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.45 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/ali-ircc.c | 12 ++++-------- drivers/net/irda/ali-ircc.h | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index 58f98f4..ab041a4 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c @@ -1462,17 +1462,13 @@ static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb, if (mtt) { /* Check how much time we have used already */ - 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); /* self->stamp is set from ali_ircc_dma_receive_complete() */ pr_debug("%s(), ******* diff = %d *******\n", __func__, diff); - - if (diff < 0) - diff += 1000000; - + /* Check if the mtt is larger than the time we have * already used by all the protocol processing */ @@ -1884,7 +1880,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self) * 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(); skb = dev_alloc_skb(len+1); if (skb == NULL) diff --git a/drivers/net/irda/ali-ircc.h b/drivers/net/irda/ali-ircc.h index 0c8edb4..164ee42 100644 --- a/drivers/net/irda/ali-ircc.h +++ b/drivers/net/irda/ali-ircc.h @@ -22,7 +22,7 @@ #ifndef ALI_IRCC_H #define ALI_IRCC_H -#include +#include #include #include @@ -209,8 +209,8 @@ struct ali_ircc_cb { unsigned char rcvFramesOverflow; - struct timeval stamp; - struct timeval now; + ktime_t stamp; + ktime_t now; spinlock_t lock; /* For serializing operations */