From patchwork Mon Nov 27 11:22:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10076621 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 72C1F6028E for ; Mon, 27 Nov 2017 11:24:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B86628DE4 for ; Mon, 27 Nov 2017 11:24:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5003B28DEA; Mon, 27 Nov 2017 11:24:33 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 01EA428DDE for ; Mon, 27 Nov 2017 11:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751944AbdK0LYb (ORCPT ); Mon, 27 Nov 2017 06:24:31 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:51008 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbdK0LY3 (ORCPT ); Mon, 27 Nov 2017 06:24:29 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0M51UE-1f3oL10jD4-00zIpD; Mon, 27 Nov 2017 12:24:25 +0100 From: Arnd Bergmann To: linux-input@vger.kernel.org, Dmitry Torokhov Cc: linux-m68k@lists.linux-m68k.org, Geert Uytterhoeven , linux-parisc@vger.kernel.org, Helge Deller , "James E . J . Bottomley" , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] Input: hp_sdc: convert to ktime_get() Date: Mon, 27 Nov 2017 12:22:59 +0100 Message-Id: <20171127112324.1917698-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171127112324.1917698-1-arnd@arndb.de> References: <20171127112324.1917698-1-arnd@arndb.de> X-Provags-ID: V03:K0:OnOSrIVpjxzbVchzul9+aLrgLPj5+ADA5QI0Jsw8quoLNchbEMH 68H2r4oOy58nkPVflvZ3nwWngS6sdkxwFVlzUGCrJlMhAMfzQ0FbZZbG7Ml4mQUbJ0Nlxq9 JD87paY4nptyyFRQNYOmCXldpx5z+JdHpmp4fVOUSctgO7hvM5ntxh7zGB4K9rDECgA9VXs rh1zpz5K4zgdYgkbmn65Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:TDK4xiN8iUU=:7mMCnUDstp4ELQktHVeVjG nt2VtWaPn6cFRc3GPuVGVMH+TmWdnlj/ZTSTm8I0W56NplHpKqt3ySmcffXWIvFBBRBWJWRIA vi5htdS+KO5nkyNbl4xfNDv/ykRl06QmF6/lHMcR83P447hraO/q0HZ7mZ4rLQcQKHiz/uuSa JeKn47PibRtVRhDzlOPiVzqpVBbLi3Fn9KqDrlsRQh6CKBp2rnGa342xd0xLxjNxO33+uHyci SYd/01qEnDJmGF4EQBACFWx9b3o1GnDfk6dUNM9dHt5Uoieojodah9RRKTWWQTKt9imZolQQx LjEJGh+fYkvoXVYDN3Y2H+95q3GP4rnZCW0g0rF3Zp4/9TCvzvx1Ee+h7Nv7xIb8l/eVqUgaW KYobB/Vow382kNpN3MnvVjvZ8rqoWvDO7PobQe6yEEqQZKXgnziN054ebeUCwyl4WYk4nOukQ /nHK45LZuQELidckkmtPpdFQ6jlCrwGeileojXQdPOM2XID+lujl+CiOJt6WQp6ewzEGr2XDV qQW9C5Uv0fORvMiJOvTBq0TCW55oKjBFT5V3gC0rQKAmvBzaLMfEXEaLTR41gc3Zh0DhX/Zlt FLikZQQWsumiYM512TC7jAZrFQIKFpN4IId5ga0dQjEOKtBY9F+rCp9AYZNtbGZJPjlJ3/7pu 7K6y8imbR+SrGPzj5Fyc0OucEp3DfbwcI5UJSW0jno1L7/LNTVSJhmjT+veKiKB4JApp22REE lrFyKmJb5ATwGscPzOHhKiDmeCmWANdXnXjJYw== 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 This gets rid of the deprecated do_gettimeofday() call in favor of ktime_get(), which is also more reliable as it uses monotonic times. The code now gets a bit simpler. Signed-off-by: Arnd Bergmann --- drivers/input/serio/hp_sdc.c | 17 +++++++---------- include/linux/hp_sdc.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 1d7c7d81a5ef..0b8a25c58d02 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c @@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data) curr->seq[curr->idx++] = status; curr->seq[curr->idx++] = data; hp_sdc.rqty -= 2; - do_gettimeofday(&hp_sdc.rtv); + hp_sdc.rtime = ktime_get(); if (hp_sdc.rqty <= 0) { /* All data has been gathered. */ @@ -306,13 +306,10 @@ static void hp_sdc_tasklet(unsigned long foo) write_lock_irq(&hp_sdc.rtq_lock); if (hp_sdc.rcurr >= 0) { - struct timeval tv; + ktime_t now = ktime_get(); - do_gettimeofday(&tv); - if (tv.tv_sec > hp_sdc.rtv.tv_sec) - tv.tv_usec += USEC_PER_SEC; - - if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { + if (ktime_after(now, ktime_add_us(hp_sdc.rtime, + HP_SDC_MAX_REG_DELAY))) { hp_sdc_transaction *curr; uint8_t tmp; @@ -321,8 +318,8 @@ static void hp_sdc_tasklet(unsigned long foo) * we'll need to figure out a way to communicate * it back to the application. and be less verbose. */ - printk(KERN_WARNING PREFIX "read timeout (%ius)!\n", - (int)(tv.tv_usec - hp_sdc.rtv.tv_usec)); + printk(KERN_WARNING PREFIX "read timeout (%lldus)!\n", + ktime_us_delta(now, hp_sdc.rtime)); curr->idx += hp_sdc.rqty; hp_sdc.rqty = 0; tmp = curr->seq[curr->actidx]; @@ -551,7 +548,7 @@ unsigned long hp_sdc_put(void) /* Start a new read */ hp_sdc.rqty = curr->seq[curr->idx]; - do_gettimeofday(&hp_sdc.rtv); + hp_sdc.rtime = ktime_get(); curr->idx++; /* Still need to lock here in case of spurious irq. */ write_lock_irq(&hp_sdc.rtq_lock); diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h index d392975d8887..6f1dee7e67e0 100644 --- a/include/linux/hp_sdc.h +++ b/include/linux/hp_sdc.h @@ -281,7 +281,7 @@ typedef struct { hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */ int rcurr, rqty; /* Current read transact in process */ - struct timeval rtv; /* Time when current read started */ + ktime_t rtime; /* Time when current read started */ int wcurr; /* Current write transact in process */ int dev_err; /* carries status from registration */