Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1531235

[PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs

From Aniroop Mathur <a.mathur@samsung.com>
Newsgroups linux.kernel
Subject [PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs
Date 2016-11-28 12:50 +0100
Message-ID <sIsBA-1xz-21@gated-at.bofh.it> (permalink)
References <sIsBA-1xz-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs Aniroop Mathur <a.mathur@samsung.com> - 2016-11-28 12:50 +0100
  Re: [PATCH] Input: joystick: adi - change msleep to usleep_range for  small msecs "vojtech@ucw.cz" <vojtech@ucw.cz> - 2016-11-28 13:20 +0100
  RE: Re: [PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs Aniroop Mathur <a.mathur@samsung.com> - 2016-11-28 14:50 +0100
    Re: Re: [PATCH] Input: joystick: adi - change msleep to usleep_range  for small msecs "vojtech@ucw.cz" <vojtech@ucw.cz> - 2016-11-29 08:00 +0100
      Re: Re: [PATCH] Input: joystick: adi - change msleep to usleep_range  for small msecs Aniroop Mathur <aniroop.mathur@gmail.com> - 2016-12-03 19:00 +0100

csiph-web