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


Groups > linux.kernel > #1318596

[PATCH v4 03/10] rtc: max77686: Use usleep_range() instead of msleep()

From Javier Martinez Canillas <javier@osg.samsung.com>
Newsgroups linux.kernel
Subject [PATCH v4 03/10] rtc: max77686: Use usleep_range() instead of msleep()
Date 2016-01-27 04:40 +0100
Message-ID <qVp7B-5OH-31@gated-at.bofh.it> (permalink)
References <qVp7A-5OH-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Documentation/timers/timers-howto.txt suggest to use usleep_range()
instead of msleep() for small msec (1ms - 20ms) since msleep() will
often sleep for 20ms for any value in that range.

This is fine in this case since 16ms is the _minimum_ delay required
by max77686 for an RTC update but by using usleep_range() instead of
msleep(), the driver can support other RTC IP blocks with a shorter
minimum delay (i.e: in the range of usecs instead of msecs).

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Andi Shyti <andi.shyti@samsung.com>

---

Changes in v4:
- Add Andi Shyti's Reviewed-by to patch #3.

Changes in v3:
- Add Krzysztof Kozlowski's Tested-by tag to patch #3.
- Add Laxman Dewangan's Acked-by tag to patch #3.

Changes in v2:
- Add Krzysztof Kozlowski's Reviewed-by tag to patch #3.
- Fix typo error in changelog. Suggested by Krzysztof Kozlowski.

 drivers/rtc/rtc-max77686.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index d84a50c9f7f7..025a17a95da3 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -41,7 +41,7 @@
 #define ALARM_ENABLE_SHIFT		7
 #define ALARM_ENABLE_MASK		(1 << ALARM_ENABLE_SHIFT)
 
-#define MAX77686_RTC_UPDATE_DELAY	16
+#define MAX77686_RTC_UPDATE_DELAY	16000
 
 enum {
 	RTC_SEC = 0,
@@ -130,7 +130,8 @@ static int max77686_rtc_update(struct max77686_rtc_info *info,
 				__func__, ret, data);
 	else {
 		/* Minimum 16ms delay required before RTC update. */
-		msleep(MAX77686_RTC_UPDATE_DELAY);
+		usleep_range(MAX77686_RTC_UPDATE_DELAY,
+			     MAX77686_RTC_UPDATE_DELAY * 2);
 	}
 
 	return ret;
-- 
2.5.0

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


Thread

[PATCH v4 00/10] rtc: max77686: Extend driver and add max77802 support Javier Martinez Canillas <javier@osg.samsung.com> - 2016-01-27 04:40 +0100
  [PATCH v4 04/10] rtc: max77686: Use a driver data struct instead hard-coded values Javier Martinez Canillas <javier@osg.samsung.com> - 2016-01-27 04:40 +0100
  [PATCH v4 03/10] rtc: max77686: Use usleep_range() instead of msleep() Javier Martinez Canillas <javier@osg.samsung.com> - 2016-01-27 04:40 +0100

csiph-web