From patchwork Thu Jan 12 16:21:45 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: 9513563 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 78BB0601E7 for ; Thu, 12 Jan 2017 16:21:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B433286DF for ; Thu, 12 Jan 2017 16:21:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FE03286E2; Thu, 12 Jan 2017 16:21:25 +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 B818C286DF for ; Thu, 12 Jan 2017 16:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750968AbdALQVX (ORCPT ); Thu, 12 Jan 2017 11:21:23 -0500 Received: from www.osadl.org ([62.245.132.105]:53093 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbdALQVX (ORCPT ); Thu, 12 Jan 2017 11:21:23 -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 v0CGKxo5020144; Thu, 12 Jan 2017 17:20:59 +0100 From: Nicholas Mc Guire To: Dmitry Torokhov Cc: Henrik Rydberg , Hans de Goede , Rob Herring , Daniel Jansen , Dan Carpenter , Robert Dolca , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] Input: silead: use msleep() for long delays Date: Thu, 12 Jan 2017 17:21:45 +0100 Message-Id: <1484238105-10785-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 the delays here are in the 10 to 20ms range so msleep() will do - no need to burden the highres timer subsystem. Signed-off-by: Nicholas Mc Guire --- Problem found by coccinelle script While msleep(10) has a worst case uncertainty of 10ms (on HZ=100 systems) this seems ok here as the delays are not called frequently (init and reset functions) and the uncertainty of 10ms fits the permitted range of the original usleep_ranges(). Patch was compile tested with: x86_64_defconfig + CONFIG_TOUCHSCREEN_SILEAD=m Patch is against 4.10-rc3 (localversion-next is next-20170112) drivers/input/touchscreen/silead.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index 404830a..3aa885c 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -58,8 +58,7 @@ #define SILEAD_POINT_X_MSB_OFF 0x03 #define SILEAD_TOUCH_ID_MASK 0xF0 -#define SILEAD_CMD_SLEEP_MIN 10000 -#define SILEAD_CMD_SLEEP_MAX 20000 +#define SILEAD_CMD_SLEEP_MIN 10 /* 10+ ms */ #define SILEAD_POWER_SLEEP 20 #define SILEAD_STARTUP_SLEEP 30 @@ -190,25 +189,25 @@ static int silead_ts_init(struct i2c_client *client) SILEAD_CMD_RESET); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); error = i2c_smbus_write_byte_data(client, SILEAD_REG_TOUCH_NR, data->max_fingers); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK, SILEAD_CLOCK); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET, SILEAD_CMD_START); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); return 0; @@ -225,19 +224,19 @@ static int silead_ts_reset(struct i2c_client *client) SILEAD_CMD_RESET); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK, SILEAD_CLOCK); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); error = i2c_smbus_write_byte_data(client, SILEAD_REG_POWER, SILEAD_CMD_START); if (error) goto i2c_write_err; - usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX); + msleep(SILEAD_CMD_SLEEP_MIN); return 0;