lkml.org 
[lkml]   [2016]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] Input: joystick: adi - chang e msleep to usleep range for small m secs
From
Date
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@samsung.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
\
 
 \ /
  Last update: 2016-11-28 12:44    [W:0.070 / U:0.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site