All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aniroop Mathur" <a.mathur@samsung.com>
To: "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>,
	"vojtech@ucw.cz" <vojtech@ucw.cz>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "SAMUEL SEQUEIRA" <s.samuel@samsung.com>,
	"Rahul Mahale" <r.mahale@samsung.com>,
	"aniroop.mathur@gmail.com" <aniroop.mathur@gmail.com>
Subject: [PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs
Date: Mon, 28 Nov 2016 11:43:56 +0000	[thread overview]
Message-ID: <20161128114356epcms5p836ef0c36a1cbb8b68638ed046afbb777@epcms5p8> (raw)
In-Reply-To: CGME20161128114356epcms5p836ef0c36a1cbb8b68638ed046afbb777@epcms5p8

[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]

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

       reply	other threads:[~2016-11-28 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161128114356epcms5p836ef0c36a1cbb8b68638ed046afbb777@epcms5p8>
2016-11-28 11:43 ` Aniroop Mathur [this message]
2016-11-28 11:53   ` [PATCH] Input: joystick: adi - change msleep to usleep_range for small msecs vojtech
2016-11-28 13:49   ` Aniroop Mathur
2016-11-29  6:59     ` vojtech
2016-12-03 17:50       ` Aniroop Mathur
2017-01-19 19:34         ` Aniroop Mathur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161128114356epcms5p836ef0c36a1cbb8b68638ed046afbb777@epcms5p8 \
    --to=a.mathur@samsung.com \
    --cc=aniroop.mathur@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=r.mahale@samsung.com \
    --cc=s.samuel@samsung.com \
    --cc=vojtech@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.