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: 119673 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1560933edl; Mon, 27 Nov 2017 03:24:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMa71bvDJ1TVQDzQ1OcAHkXBEll7Y029H4h7nQLOas+yOS+FdhELZmu565hEMHptNO+B0dBp X-Received: by 10.101.100.215 with SMTP id t23mr10979409pgv.433.1511781873302; Mon, 27 Nov 2017 03:24:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511781873; cv=none; d=google.com; s=arc-20160816; b=faY9iXI4lzI/D/ufLZYQvMtBmv1X4KzH1AU76/F211OmrQtXD3F8uaG+hNY50wgx3o PCI9uxPS1uIsVN/4PBKZkkG1/13C0x2MXKZK7AMFKtKQ6HzYn5gNxOUhg5aXsiD+iJiB QyqgYM95dG8EfoFXF1RURXzUlF4Cwa/bGFRful1EB7cVakQd8JqBxi89kCC42x9kr7aa 1ndbmiC1iYkshlf1+84VyRMXV33mdZZTFWBEgBw4+6IMWqBFxJvGRj6iRwQbQP0HqzJz eCCADuFE1+oLHZ06w6BAIPgGGPAMP3d7aoLEnsqqUBbw4dGR++MvJ3ZPdpLCnzCVYGjD jfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=a7uNH1LIx4mgmgGyqm8cFouJRT3BfqGQmWx3DM7F8s8=; b=WglhMuo9zrRosYx/YOYfUi0FHgnLtR9l4NaQ1xX4udThAjcUOyAwvvlvfVSk4dndIK 5+qr6KLZ69Vo6+rrHJoE4sc9e3SXKfszUFLE5SkgGrfxml6d640ztrvfdN05yq6hcahZ YKdGO9KGUzYEyY3mMkagUgjdUiGEp9UyGqyr8F8PFM3P1K7xXnGaJy4mcgha5B0uNjH7 S8//86ePAr8ONXqX7wUI/2kiXzPnPEQmqlhrevOGvlZuJ1wtcOVqgurFdjoILfInICsu dma7+Hp6pbehX5OPylv0hNql2R05SB9v6hZR9vO0FNrElm62XKWrmsqd/5y0gJmRXxO1 oMMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r59si18290083plb.59.2017.11.27.03.24.33 for ; Mon, 27 Nov 2017 03:24:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org 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 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(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 */