From patchwork Sun Jan 15 11:13:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 9517355 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 CAC5C60571 for ; Sun, 15 Jan 2017 11:12:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8FD32819A for ; Sun, 15 Jan 2017 11:12:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD4872840A; Sun, 15 Jan 2017 11:12:01 +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=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 4ED5C2819A for ; Sun, 15 Jan 2017 11:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751112AbdAOLMA (ORCPT ); Sun, 15 Jan 2017 06:12:00 -0500 Received: from www.osadl.org ([62.245.132.105]:45395 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbdAOLL7 (ORCPT ); Sun, 15 Jan 2017 06:11:59 -0500 Received: from debian01.hofrr.at (92-243-34-74.adsl.nanet.at [92.243.34.74] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id v0FBBmxH028980; Sun, 15 Jan 2017 12:11:48 +0100 From: Nicholas Mc Guire To: Dmitry Torokhov Cc: Henrik Rydberg , Dudley Du , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] Input: cyapa_gen3: use msleep() for long delay Date: Sun, 15 Jan 2017 12:13:07 +0100 Message-Id: <1484478787-13178-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 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 ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 50ms delays here to use msleep() and reduce the load on the hrtimer subsystem. Signed-off-by: Nicholas Mc Guire --- Problem found by coccinelle script As the needed delay is specified in the comment as being "at least 50ms" the msleep(50) should be fine here. Note that cyapa_gen3_bl_exit() is returning -EAGAIN in cases where it was not yet ready to process the request, but the calling side cyapa_gen3_do_operational_check() does not check for -EAGAIN so in case of the noted increased delay "...can take up to an additional 2 seconds. If the device power is running low, this may take even longer", maybe cyapa_gen3_do_operational_check() may need a retry loop on -EAGAIN ? Patch was compile tested with: x86_64_defconfig + CONFIG_MOUSE_CYAPA=m Patch is against 4.10-rc3 (localversion-next is next-20170113) drivers/input/mouse/cyapa_gen3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c index f9600753..6e9ecb0 100644 --- a/drivers/input/mouse/cyapa_gen3.c +++ b/drivers/input/mouse/cyapa_gen3.c @@ -562,7 +562,7 @@ static int cyapa_gen3_bl_exit(struct cyapa *cyapa) * Wait for bootloader to exit, and operation mode to start. * Normally, this takes at least 50 ms. */ - usleep_range(50000, 100000); + msleep(50); /* * In addition, when a device boots for the first time after being * updated to new firmware, it must first calibrate its sensors, which