[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <20161128114356epcms5p836ef0c36a1cbb8b68638ed046afbb777@epcms5p8>
Date: Mon, 28 Nov 2016 11:43:56 +0000
From: Aniroop Mathur <a.mathur@...sung.com>
To: dmitry.torokhov@...il.com
<dmitry.torokhov@...il.com>,
vojtech@....cz <vojtech@....cz>,
linux-input@...r.kernel.org
<linux-input@...r.kernel.org>,
linux-kernel@...r.kernel.org
<linux-kernel@...r.kernel.org>
Cc: SAMUEL SEQUEIRA <s.samuel@...sung.com>,
Rahul Mahale <r.mahale@...sung.com>,
aniroop.mathur@...il.com
<aniroop.mathur@...il.com>
Subject: [PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs
msleep(1~20) may not do what the caller intends, and will often sleep longer.
(~20 ms actual sleep for any value given in the 1~20ms range)
This is not the desired behaviour for many cases like device resume time,
device suspend time, device enable time, data reading time, etc.
Thus, change msleep to usleep_range for precise wakeups.
Signed-off-by: Aniroop Mathur <a.mathur@...sung.com>
---
joystick/adi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/joystick/adi.c b/joystick/adi.c
index d09cefa..6799bd9 100644
--- a/joystick/adi.c
+++ b/joystick/adi.c
@@ -47,8 +47,8 @@ MODULE_LICENSE("GPL");
#define ADI_MAX_START 200 /* Trigger to packet timeout [200us] */
#define ADI_MAX_STROBE 40 /* Single bit timeout [40us] */
-#define ADI_INIT_DELAY 10 /* Delay after init packet [10ms] */
-#define ADI_DATA_DELAY 4 /* Delay after data packet [4ms] */
+#define ADI_INIT_DELAY 10000 /* Delay after init packet [10ms] */
+#define ADI_DATA_DELAY 4000 /* Delay after data packet [4000us] */
#define ADI_MAX_LENGTH 256
#define ADI_MIN_LENGTH 8
@@ -319,7 +319,7 @@ static void adi_init_digital(struct gameport *gameport)
for (i = 0; seq[i]; i++) {
gameport_trigger(gameport);
if (seq[i] > 0)
- msleep(seq[i]);
+ usleep_range(seq[i] * 1000, (seq[i] * 1000) + 100);
if (seq[i] < 0) {
mdelay(-seq[i]);
udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */
@@ -512,9 +512,9 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
gameport_set_poll_handler(gameport, adi_poll);
gameport_set_poll_interval(gameport, 20);
- msleep(ADI_INIT_DELAY);
+ usleep_range(ADI_INIT_DELAY, ADI_INIT_DELAY + 100);
if (adi_read(port)) {
- msleep(ADI_DATA_DELAY);
+ usleep_range(ADI_DATA_DELAY, ADI_DATA_DELAY + 100);
adi_read(port);
}
--
2.6.4.windows.1
Powered by blists - more mailing lists