From patchwork Mon Dec 18 05:18:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 10118255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C803603FA for ; Mon, 18 Dec 2017 05:19:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FD1428CBB for ; Mon, 18 Dec 2017 05:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 344E528DA8; Mon, 18 Dec 2017 05:19:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EAAF28CBB for ; Mon, 18 Dec 2017 05:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757984AbdLRFTc (ORCPT ); Mon, 18 Dec 2017 00:19:32 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:40384 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757884AbdLRFTb (ORCPT ); Mon, 18 Dec 2017 00:19:31 -0500 Received: by mail-pl0-f66.google.com with SMTP id 62so2745682pld.7; Sun, 17 Dec 2017 21:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mp+6TRF4oR8O4grjlT28VwT9Jt8wZA391q09r5Zo8Y8=; b=YWYLOxieHtMNBSxbeDSEi9EdYKjZPsdFJ6ftk9KGimKGfbPLIKJj5WZQKi17yk5jS3 lvX57QZamWZslvZzmSo1XsRYAUE28ZYgxG6SG2Pvggw0uS8r9fIKPH0/TaR5+p4XXTSn dTR+aw0OvFv752lZ7EPGpbgztr0DGln0/amGuW14XY55S3OKeuqqEF8yk00twHz4JI/v P/4fjKOJNHvKb60QxvGFpGCjEFwxPPeQMgOQHCS7aaoq0zarhvJ3qo9rTrmvHbSTVtAN dqHxFWsFlxqSgKDXx6XoXVATjpYTmS62xWTEAw8+iiSoJvelnACVMTff31j5Gay1m8Pz u4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Mp+6TRF4oR8O4grjlT28VwT9Jt8wZA391q09r5Zo8Y8=; b=PzTAIGH0Rrsz4KZY5ODL0SLuI9cRdGP7BgLTyy9xyR74z19n9TmaPzMMllwn0D4l9Q vbXuiJc0Txw6kOo6cwpabqUcsNvF2lRrq6i7hqMHmiaee6su0T2B2Pi/F66eKslMwYLF /2rm23LSmEzKmXAc31e3UVli+IbS+5y/7A1QjKng+iC3fhhYzZ1Y/s3lHSt0FDCtR1nc xtgWTYzox97riiSX3jEXEIcv2ChGJw+RNUnE5sf9bXwSdKyUgwNTOeCpBSyJ8QAAdG+q +vVlNy1AC3R1veFG27M0HC6U5wfKSZIyrfzrFmiMsf+trAawZtnVTS+kstKJBL28or8I VsCA== X-Gm-Message-State: AKGB3mKACtQw1PgOaWMS7ykT69oMFVP4sVn/Q+k9So60b1a1PwfTu4a9 tQTzf6XO3PKqkVBYgFeydb+qhw== X-Google-Smtp-Source: ACJfBouETGHLg+6dhJNJK/7Tj47H3LQ+z0/QiVo/C4dWVDZ26rzOH7gT0k0a1oh23mUa9ra5HAIR9A== X-Received: by 10.84.242.69 with SMTP id c5mr20978615pll.73.1513574371048; Sun, 17 Dec 2017 21:19:31 -0800 (PST) Received: from deepa-ubuntu.hsd1.ca.comcast.net ([2601:647:5000:6620:ad71:44a1:71af:39e7]) by smtp.gmail.com with ESMTPSA id q72sm25109081pfi.42.2017.12.17.21.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 21:19:30 -0800 (PST) From: Deepa Dinamani To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peter.hutterer@who-t.net, arnd@arndb.de, y2038@lists.linaro.org Subject: [PATCH v5 1/3] uinput: Use monotonic times for uinput timestamps. Date: Sun, 17 Dec 2017 21:18:42 -0800 Message-Id: <20171218051844.10193-2-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171218051844.10193-1-deepa.kernel@gmail.com> References: <20171218051844.10193-1-deepa.kernel@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct timeval which is part of struct input_event to maintain the event times is not y2038 safe. Real time timestamps are also not ideal for input_event as this time can go backwards as noted in the patch a80b83b7b8 by John Stultz. The patch switches the timestamps to use monotonic time from realtime time. This is assuming no one is using absolute times from these timestamps. The structure to maintain input events will be changed in a different patch. Signed-off-by: Deepa Dinamani Acked-by: Peter Hutterer --- drivers/input/misc/uinput.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 91df0df15e68..9251765645d1 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -84,11 +84,14 @@ static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { struct uinput_device *udev = input_get_drvdata(dev); + struct timespec64 ts; udev->buff[udev->head].type = type; udev->buff[udev->head].code = code; udev->buff[udev->head].value = value; - do_gettimeofday(&udev->buff[udev->head].time); + ktime_get_ts64(&ts); + udev->buff[udev->head].time.tv_sec = ts.tv_sec; + udev->buff[udev->head].time.tv_usec = ts.tv_nsec / NSEC_PER_USEC; udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE; wake_up_interruptible(&udev->waitq);