Patchwork rtc/ab8500: change to msleep to usleep_range

login
register
mail settings
Submitter Linus Walleij
Date Dec. 1, 2011, 2:37 p.m.
Message ID <1322750260-26157-1-git-send-email-linus.walleij@stericsson.com>
Download mbox | patch
Permalink /patch/128705/
State New
Headers show

Comments

Linus Walleij - Dec. 1, 2011, 2:37 p.m.
From: Linus Walleij <linus.walleij@linaro.org>

The resolution of msleep is related to HZ, so with HZ set to
100 any msleep of less than 10ms will become ~10ms. This is not
what we want. Use usleep_range() and allow for some slack in
the non-critical path so we have more control of what is
happening here.

Cc: Jonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
This replaces the earlier patch titled "change msleep to
mdelay".
---
 drivers/rtc/rtc-ab8500.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Jean-Christophe PLAGNIOL-VILLARD - Dec. 1, 2011, 5:44 p.m.
On 15:37 Thu 01 Dec     , Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> The resolution of msleep is related to HZ, so with HZ set to
> 100 any msleep of less than 10ms will become ~10ms. This is not
> what we want. Use usleep_range() and allow for some slack in
> the non-critical path so we have more control of what is
> happening here.
> 
> Cc: Jonas Aaberg <jonas.aberg@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> This replaces the earlier patch titled "change msleep to
> mdelay".
> ---
>  drivers/rtc/rtc-ab8500.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
> index 82a3480..919b2e5 100644
> --- a/drivers/rtc/rtc-ab8500.c
> +++ b/drivers/rtc/rtc-ab8500.c
> @@ -90,7 +90,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  
>  	/* Early AB8500 chips will not clear the rtc read request bit */
>  	if (abx500_get_chip_id(dev) == 0) {
> -		msleep(1);
> +		usleep_range(1000, 1000);
can you explain a bit the requirement in a comment
>  	} else {
>  		/* Wait for some cycles after enabling the rtc read in ab8500 */
>  		while (time_before(jiffies, timeout)) {
> @@ -102,7 +102,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  			if (!(value & RTC_READ_REQUEST))
>  				break;
>  
> -			msleep(1);
> +			usleep_range(1000, 5000);
>  		}
>  	}
>  
> @@ -295,7 +295,7 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
>  		return err;
>  
>  	/* Wait for reset by the PorRtc */
> -	msleep(1);
> +	usleep_range(1000, 5000);
ditto

Best Regards,
J.

Patch

diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 82a3480..919b2e5 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -90,7 +90,7 @@  static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
 
 	/* Early AB8500 chips will not clear the rtc read request bit */
 	if (abx500_get_chip_id(dev) == 0) {
-		msleep(1);
+		usleep_range(1000, 1000);
 	} else {
 		/* Wait for some cycles after enabling the rtc read in ab8500 */
 		while (time_before(jiffies, timeout)) {
@@ -102,7 +102,7 @@  static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
 			if (!(value & RTC_READ_REQUEST))
 				break;
 
-			msleep(1);
+			usleep_range(1000, 5000);
 		}
 	}
 
@@ -295,7 +295,7 @@  static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
 		return err;
 
 	/* Wait for reset by the PorRtc */
-	msleep(1);
+	usleep_range(1000, 5000);
 
 	err = abx500_get_register_interruptible(&pdev->dev, AB8500_RTC,
 		AB8500_RTC_STAT_REG, &rtc_ctrl);