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


Groups > linux.kernel > #1559208 > unrolled thread

[PATCH] Input: cyapa_gen3: use msleep() for long delay

Started byNicholas Mc Guire <hofrat@osadl.org>
First post2017-01-15 12:20 +0100
Last post2017-01-16 00:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Input: cyapa_gen3: use msleep() for long delay Nicholas Mc Guire <hofrat@osadl.org> - 2017-01-15 12:20 +0100
    Re: [PATCH] Input: cyapa_gen3: use msleep() for long delay Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-01-16 00:30 +0100

#1559208 — [PATCH] Input: cyapa_gen3: use msleep() for long delay

FromNicholas Mc Guire <hofrat@osadl.org>
Date2017-01-15 12:20 +0100
Subject[PATCH] Input: cyapa_gen3: use msleep() for long delay
Message-ID<sZR0R-1S5-1@gated-at.bofh.it>
ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 50ms delays here to use msleep() and
reduce the load on the hrtimer subsystem. 

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Problem found by coccinelle script

As the needed delay is specified in the comment as being "at least 50ms"
the msleep(50) should be fine here. 

Note that cyapa_gen3_bl_exit() is returning -EAGAIN in cases where it was
not yet ready to process the request, but the calling side 
cyapa_gen3_do_operational_check() does not check for -EAGAIN so in case of
the noted increased delay "...can take up to an additional 2 seconds. If 
the device power is running low, this may take even longer", maybe
cyapa_gen3_do_operational_check() may need a retry loop on -EAGAIN ?

Patch was compile tested with: x86_64_defconfig + CONFIG_MOUSE_CYAPA=m

Patch is against 4.10-rc3 (localversion-next is next-20170113)

 drivers/input/mouse/cyapa_gen3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c
index f9600753..6e9ecb0 100644
--- a/drivers/input/mouse/cyapa_gen3.c
+++ b/drivers/input/mouse/cyapa_gen3.c
@@ -562,7 +562,7 @@ static int cyapa_gen3_bl_exit(struct cyapa *cyapa)
 	 * Wait for bootloader to exit, and operation mode to start.
 	 * Normally, this takes at least 50 ms.
 	 */
-	usleep_range(50000, 100000);
+	msleep(50);
 	/*
 	 * In addition, when a device boots for the first time after being
 	 * updated to new firmware, it must first calibrate its sensors, which
-- 
2.1.4

[toc] | [next] | [standalone]


#1559363

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-01-16 00:30 +0100
Message-ID<t02pk-ml-11@gated-at.bofh.it>
In reply to#1559208
On Sun, Jan 15, 2017 at 12:13:07PM +0100, Nicholas Mc Guire wrote:
> ulseep_range() uses hrtimers and provides no advantage over msleep()
> for larger delays. Fix up the 50ms delays here to use msleep() and
> reduce the load on the hrtimer subsystem. 
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

Applied, thank you.

> ---
> Problem found by coccinelle script
> 
> As the needed delay is specified in the comment as being "at least 50ms"
> the msleep(50) should be fine here. 
> 
> Note that cyapa_gen3_bl_exit() is returning -EAGAIN in cases where it was
> not yet ready to process the request, but the calling side 
> cyapa_gen3_do_operational_check() does not check for -EAGAIN so in case of
> the noted increased delay "...can take up to an additional 2 seconds. If 
> the device power is running low, this may take even longer", maybe
> cyapa_gen3_do_operational_check() may need a retry loop on -EAGAIN ?
> 
> Patch was compile tested with: x86_64_defconfig + CONFIG_MOUSE_CYAPA=m
> 
> Patch is against 4.10-rc3 (localversion-next is next-20170113)
> 
>  drivers/input/mouse/cyapa_gen3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c
> index f9600753..6e9ecb0 100644
> --- a/drivers/input/mouse/cyapa_gen3.c
> +++ b/drivers/input/mouse/cyapa_gen3.c
> @@ -562,7 +562,7 @@ static int cyapa_gen3_bl_exit(struct cyapa *cyapa)
>  	 * Wait for bootloader to exit, and operation mode to start.
>  	 * Normally, this takes at least 50 ms.
>  	 */
> -	usleep_range(50000, 100000);
> +	msleep(50);
>  	/*
>  	 * In addition, when a device boots for the first time after being
>  	 * updated to new firmware, it must first calibrate its sensors, which
> -- 
> 2.1.4
> 

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web