All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@ucw.cz>
To: Aniroop Mathur <a.mathur@samsung.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, s.samuel@samsung.com,
	r.mahale@samsung.com, aniroop.mathur@gmail.com
Subject: Re: [PATCH] Input: joystick: gf2k - change msleep to usleep_range for small msecs
Date: Tue, 29 Nov 2016 07:51:55 +0100	[thread overview]
Message-ID: <20161129065155.GD10549@suse.com> (raw)
In-Reply-To: <1480362109-4818-1-git-send-email-a.mathur@samsung.com>

On Tue, Nov 29, 2016 at 01:11:49AM +0530, Aniroop Mathur wrote:

> 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, connection time, probe time,
> loops, retry logic, etc
> msleep is built on jiffies / legacy timers which are not precise whereas
> usleep_range is build on top of hrtimers so the wakeups are precise.
> Thus, change msleep to usleep_range for precise wakeups.
> 
> For example:
> On a machine with tick rate / HZ as 100, msleep(4) will make the process to
> sleep for a minimum period of 10 ms whereas usleep_range(4000, 4100) will make
> sure that the process does not sleep for more than 4100 us or 4.1ms

And once more, patch not needed.

> 
> Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
> ---
>  drivers/input/joystick/gf2k.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
> index 0f519db..e9d5095 100644
> --- a/drivers/input/joystick/gf2k.c
> +++ b/drivers/input/joystick/gf2k.c
> @@ -42,7 +42,7 @@ MODULE_LICENSE("GPL");
>  
>  #define GF2K_START		400	/* The time we wait for the first bit [400 us] */
>  #define GF2K_STROBE		40	/* The time we wait for the first bit [40 us] */
> -#define GF2K_TIMEOUT		4	/* Wait for everything to settle [4 ms] */
> +#define GF2K_TIMEOUT		4000	/* Wait for everything to settle [4000 us] */
>  #define GF2K_LENGTH		80	/* Max number of triplets in a packet */
>  
>  /*
> @@ -138,7 +138,7 @@ static void gf2k_trigger_seq(struct gameport *gameport, short *seq)
>  	i = 0;
>          do {
>  		gameport_trigger(gameport);
> -		t = gameport_time(gameport, GF2K_TIMEOUT * 1000);
> +		t = gameport_time(gameport, GF2K_TIMEOUT);
>  		while ((gameport_read(gameport) & 1) && t) t--;
>                  udelay(seq[i]);
>          } while (seq[++i]);
> @@ -259,11 +259,11 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
>  
>  	gf2k_trigger_seq(gameport, gf2k_seq_reset);
>  
> -	msleep(GF2K_TIMEOUT);
> +	usleep_range(GF2K_TIMEOUT, GF2K_TIMEOUT + 100);
>  
>  	gf2k_trigger_seq(gameport, gf2k_seq_digital);
>  
> -	msleep(GF2K_TIMEOUT);
> +	usleep_range(GF2K_TIMEOUT, GF2K_TIMEOUT + 100);
>  
>  	if (gf2k_read_packet(gameport, GF2K_LENGTH, data) < 12) {
>  		err = -ENODEV;
> -- 
> 2.6.2
> 

-- 
Vojtech Pavlik

      reply	other threads:[~2016-11-29  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 19:41 [PATCH] Input: joystick: gf2k - change msleep to usleep_range for small msecs Aniroop Mathur
2016-11-29  6:51 ` Vojtech Pavlik [this message]

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=20161129065155.GD10549@suse.com \
    --to=vojtech@ucw.cz \
    --cc=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 \
    /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.