From patchwork Thu Jan 8 04:01:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A24EF2055F for ; Thu, 8 Jan 2015 04:03:32 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u14sf542270lbd.3 for ; Wed, 07 Jan 2015 20:03:31 -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=393vDgGuKJwM/cZcK706ogUcGh1T2z1Sq5DTyIR/J4s=; b=nFkUTENdY0xeuhLswLd2Fk9n4oyvz1/Z//Pm6DZTD8atDPAwpwRWzLme3XcLIVJfgF owfOArVk0XAPSDv3toOA7j0zVnYE8D3Ax5wxKv+Wm7vDlNLQmIXhlPl3/uqwa3rvyh33 ir7mgeDjw5+LeoGuHJ7aGlM1H5xHDivZKG1TdOL1xq3kgZ3XZHbbao+M7Aia/N9MXkvW qdYCZAEi/Z6cTOoUfn/DjpQyq7/FxjGHi/6s3kNKtExqZ+IsSRRv4wvBBL15Be3pBCX4 4Ur6D65jvjz/C4aoc3pP8zyRVnwDdNNJ2B/SANAZajvSWmSAteY7GTCCUJzvivSjL0I8 6KRw== X-Gm-Message-State: ALoCoQn1q9Ggx05wI9ER1QEnlgb0tZNbzKlABp+92ZX1r+yhZhV5R2WyMJh/DlMG5FYvrm5tLg7i X-Received: by 10.180.108.101 with SMTP id hj5mr949163wib.3.1420689811601; Wed, 07 Jan 2015 20:03:31 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.49 with SMTP id bd17ls243103lab.14.gmail; Wed, 07 Jan 2015 20:03:31 -0800 (PST) X-Received: by 10.112.209.40 with SMTP id mj8mr9770555lbc.49.1420689811344; Wed, 07 Jan 2015 20:03:31 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id lt6si6051367lac.47.2015.01.07.20.03.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 20:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id z12so895260lbi.3 for ; Wed, 07 Jan 2015 20:03:31 -0800 (PST) X-Received: by 10.112.52.229 with SMTP id w5mr9999747lbo.52.1420689811184; Wed, 07 Jan 2015 20:03:31 -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 c8csp145795lbb; Wed, 7 Jan 2015 20:03:30 -0800 (PST) X-Received: by 10.66.66.102 with SMTP id e6mr11630772pat.6.1420689779393; Wed, 07 Jan 2015 20:02:59 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si6383327pdj.119.2015.01.07.20.02.57; Wed, 07 Jan 2015 20:02:59 -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 S1755886AbbAHECr (ORCPT + 27 others); Wed, 7 Jan 2015 23:02:47 -0500 Received: from mail-pd0-f176.google.com ([209.85.192.176]:50821 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753352AbbAHECo (ORCPT ); Wed, 7 Jan 2015 23:02:44 -0500 Received: by mail-pd0-f176.google.com with SMTP id r10so8715950pdi.7 for ; Wed, 07 Jan 2015 20:02:44 -0800 (PST) X-Received: by 10.70.50.41 with SMTP id z9mr647160pdn.31.1420689763954; Wed, 07 Jan 2015 20:02:43 -0800 (PST) Received: from chunyanzhangubtpc.spreadtrum.com ([203.160.240.81]) by mx.google.com with ESMTPSA id mw3sm3067779pdb.70.2015.01.07.20.02.40 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 20:02:42 -0800 (PST) From: Chunyan Zhang To: samuel@sortiz.org Cc: arnd@arndb.de, zhang.lyra@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] irda: ali-ircc: Replace timeval with ktime_t Date: Thu, 8 Jan 2015 12:01:28 +0800 Message-Id: <1420689692-8760-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1420689692-8760-1-git-send-email-zhang.chunyan@linaro.org> References: <1420689692-8760-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.172 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: , The ali ircc driver uses 'timeval', which we try to remove in the kernel because all 32-bit time types will break in the year 2038. 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 uses 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 Reviewed-by: Arnd Bergmann --- drivers/net/irda/ali-ircc.c | 11 +++-------- drivers/net/irda/ali-ircc.h | 5 ++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index 58f98f4..58ae11a 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c @@ -1462,17 +1462,12 @@ 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; + diff = ktime_us_delta(ktime_get(), 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 +1879,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..c2d9747 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,7 @@ struct ali_ircc_cb { unsigned char rcvFramesOverflow; - struct timeval stamp; - struct timeval now; + ktime_t stamp; spinlock_t lock; /* For serializing operations */