From patchwork Thu Jan 8 04:01:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 42862 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A638126CFD for ; Thu, 8 Jan 2015 04:03:33 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf4208163eek.1 for ; Wed, 07 Jan 2015 20:03:32 -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=vD7QF1G4uEkkh/MR8aF3hScuiGCbC039EC+N+ncV5CA=; b=hHDPp3uruu202nwpx80qbfcdn7cy/Pc+wQuAiDv/psSCz6B3jL1JKqrKtO9cZCR+XP 9RnjdYLVTEsdR1bhoxq/DuwAWkQQ7iZOd+lFVoG1GO5l3ectAqjgZ/l+/HhR4Z8mTgHD uHofLX8tA5mkkVixnZCDREbKsBpEXTGfVHg0w0MugrMhHQRyp0ph2KZSkOID4/3UbiIA BiUpMPyxPISIStl1fsyrfc13zBlx9U9qDC28QF4gutQW2wTEtFK3zXFynF+DHsjI5h7y Q0Umpl2Avygozoa6kOb6E5LCpS1ai0CC+Q675a/JKoT8VJlTZ9ETGoKF/j7rNxXzPMVm DAcA== X-Gm-Message-State: ALoCoQlG8Qq+yVRqv6Q/+an9d/KJ2oPVFFMJGGtrVTUzv3UZw14Z82mnpVmQ16qT2MEDVK6A2ttQ X-Received: by 10.112.141.232 with SMTP id rr8mr885498lbb.0.1420689812801; Wed, 07 Jan 2015 20:03:32 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.132 with SMTP id dc4ls210057lad.97.gmail; Wed, 07 Jan 2015 20:03:32 -0800 (PST) X-Received: by 10.112.172.167 with SMTP id bd7mr10125786lbc.14.1420689812535; Wed, 07 Jan 2015 20:03:32 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id uo8si6000222lbb.96.2015.01.07.20.03.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 20:03:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so7168329lab.8 for ; Wed, 07 Jan 2015 20:03:32 -0800 (PST) X-Received: by 10.112.64.35 with SMTP id l3mr9906699lbs.82.1420689812416; Wed, 07 Jan 2015 20:03:32 -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 c8csp145797lbb; Wed, 7 Jan 2015 20:03:31 -0800 (PST) X-Received: by 10.66.156.38 with SMTP id wb6mr11149866pab.139.1420689810311; Wed, 07 Jan 2015 20:03:30 -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.03.29; Wed, 07 Jan 2015 20:03:30 -0800 (PST) Received-SPF: none (google.com: netdev-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 S1755932AbbAHECs (ORCPT + 3 others); Wed, 7 Jan 2015 23:02:48 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:42366 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753352AbbAHECr (ORCPT ); Wed, 7 Jan 2015 23:02:47 -0500 Received: by mail-pa0-f54.google.com with SMTP id fb1so9090810pad.13 for ; Wed, 07 Jan 2015 20:02:47 -0800 (PST) X-Received: by 10.70.55.163 with SMTP id t3mr836949pdp.8.1420689767194; Wed, 07 Jan 2015 20:02:47 -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.44 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 20:02:46 -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 3/6] irda: irda-usb: Replace timeval with ktime_t Date: Thu, 8 Jan 2015 12:01:29 +0800 Message-Id: <1420689692-8760-4-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: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@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.49 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 irda usb 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/irda-usb.c | 10 ++-------- drivers/net/irda/irda-usb.h | 5 ++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 48b2f9a..f6c9163 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -495,18 +495,12 @@ 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; + diff = ktime_us_delta(ktime_get(), 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 +863,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..8ac389f 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,7 @@ struct irda_usb_cb { char *speed_buff; /* Buffer for speed changes */ char *tx_buff; - struct timeval stamp; - struct timeval now; + ktime_t stamp; spinlock_t lock; /* For serializing Tx operations */