From patchwork Thu Sep 17 03:09:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingbo Wen X-Patchwork-Id: 53773 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 5805922DB2 for ; Thu, 17 Sep 2015 03:11:19 +0000 (UTC) Received: by lagj9 with SMTP id j9sf1652074lag.0 for ; Wed, 16 Sep 2015 20:11:18 -0700 (PDT) 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=nCf4/E0UDu0IYaaLfJQe5FgcbUZa7UEVId5IBJXJQoQ=; b=iDdpei9QBPi3ZwWtEQZz669NTt12eKPNt5/Kh9U4aQ3wodF50wLwqTSZQVFkvSB6YB 101Fgn7hkyru4Fbni7xE5/eQr6nQCoDJayoOXfCq7RdOv3gZ583qqTTsvYX9fGlidSdP ep3dHoJu6c7BYButlm3oenyWkg2xk8otJsF94eE5xgiB5N0W/mIj0BsdKnzuRCUB5ER1 8/sFzLUX85QGBeFAb59CYLqt1coaebhdcedIrTzdY/pLJkZ/4N6dZ46TH19sWLqeJNx5 Aq7nclmNF5loHIo19u1ZsEfxl+K+CH02A+zHnm83l3X6B3ku3coq0hY4rafM7ppj9JVJ 4w+Q== X-Gm-Message-State: ALoCoQmwDYr95YOQLgYjY05QgK3a03fXCTeO17/CzLaMErh17ZcGdPQz+fFrgQO6gWz5oD8LoJ7f X-Received: by 10.152.6.201 with SMTP id d9mr5597965laa.6.1442459478092; Wed, 16 Sep 2015 20:11:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.196 with SMTP id y4ls23136lad.34.gmail; Wed, 16 Sep 2015 20:11:17 -0700 (PDT) X-Received: by 10.112.160.98 with SMTP id xj2mr33876680lbb.124.1442459477800; Wed, 16 Sep 2015 20:11:17 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id m5si581588lbp.169.2015.09.16.20.11.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2015 20:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lahg1 with SMTP id g1so3088099lah.1 for ; Wed, 16 Sep 2015 20:11:17 -0700 (PDT) X-Received: by 10.112.72.97 with SMTP id c1mr33383081lbv.86.1442459477633; Wed, 16 Sep 2015 20:11:17 -0700 (PDT) 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.59.35 with SMTP id w3csp2816485lbq; Wed, 16 Sep 2015 20:11:16 -0700 (PDT) X-Received: by 10.107.46.228 with SMTP id u97mr2042610iou.165.1442459476653; Wed, 16 Sep 2015 20:11:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si608552igj.69.2015.09.16.20.11.16; Wed, 16 Sep 2015 20:11:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752563AbbIQDLO (ORCPT + 4 others); Wed, 16 Sep 2015 23:11:14 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35812 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751708AbbIQDLN (ORCPT ); Wed, 16 Sep 2015 23:11:13 -0400 Received: by pacfv12 with SMTP id fv12so7009475pac.2 for ; Wed, 16 Sep 2015 20:11:13 -0700 (PDT) X-Received: by 10.68.202.9 with SMTP id ke9mr5850203pbc.85.1442459473171; Wed, 16 Sep 2015 20:11:13 -0700 (PDT) Received: from localhost.localdomain ([202.130.115.78]) by smtp.gmail.com with ESMTPSA id we9sm837075pab.3.2015.09.16.20.11.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Sep 2015 20:11:12 -0700 (PDT) From: WEN Pingbo To: linux-usb@vger.kernel.org Cc: WEN Pingbo , Y2038 , linux-kernel@vger.kernel.org, Arnd Bergmann , Felipe Balbi Subject: [PATCH V2] dummy_hcd: replace timeval with timespec64 Date: Thu, 17 Sep 2015 11:09:49 +0800 Message-Id: <1442459389-11171-1-git-send-email-pingbo.wen@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <2640620.MF43KccxAS@wuerfel> References: <2640620.MF43KccxAS@wuerfel> Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pingbo.wen@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.43 as permitted sender) smtp.mailfrom=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 millisecond of the last second will be normal if tv_sec is overflowed. But for y2038 consistency and demonstration purpose, and avoiding further risks, we need to remove 'timeval' in this driver, to avoid similair problems. V2 Updates: - using monotonic time here by replacing getnstimeofday() with ktime_get_ts64(), to avoid leap second issues. The frame time in USB is always 1ms, no matter what speed, so ktime_get_ts64() have enough resolution to cover this. - using NSEC_PER_MSEC instead of hard code. Signed-off-by: Pingbo Wen Cc: Y2038 Cc: linux-kernel@vger.kernel.org Cc: Arnd Bergmann Cc: Felipe Balbi Signed-off-by: WEN Pingbo Reviewed-by: Arnd Bergmann --- drivers/usb/gadget/udc/dummy_hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 1379ad4..6d1ed35 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -833,10 +833,10 @@ static const struct usb_ep_ops dummy_ep_ops = { /* there are both host and device side versions of this call ... */ static int dummy_g_get_frame(struct usb_gadget *_gadget) { - struct timeval tv; + struct timespec64 tv; - do_gettimeofday(&tv); - return tv.tv_usec / 1000; + ktime_get_ts64(&tv); + return tv.tv_nsec / NSEC_PER_MSEC; } static int dummy_wakeup(struct usb_gadget *_gadget)