summaryrefslogtreecommitdiffstats
path: root/common/clock.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-10-29 14:02:35 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-29 22:31:18 +0100
commitcf1670486b0b315c911e947a732f3bc603fe2438 (patch)
tree5f163ca44623fba8e239e64a18f08b962a90e876 /common/clock.c
parent72703410feff9ed44779b54a41ff30312e781279 (diff)
downloadbarebox-cf1670486b0b315c911e947a732f3bc603fe2438.tar.gz
clock: introduce non interruptible timeout
is_timeout call poller_call if the timeout is >= 100us but on 1-wire bus we need to wait 500us and not more than 930us for the bus reset. So if the poller_call is caller we can not guarantee it. So for this introduce is_non_interruptible_timeout than we only wait. Use it for ndelay too. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/clock.c')
-rw-r--r--common/clock.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/common/clock.c b/common/clock.c
index 8adbeaf..9c7c1ba 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -135,23 +135,29 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant)
return (uint32_t)tmp;
}
-int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns)
{
- if (time_offset_ns >= 100 * USECOND)
- poller_call();
-
if ((int64_t)(start_ns + time_offset_ns - get_time_ns()) < 0)
return 1;
else
return 0;
}
+EXPORT_SYMBOL(is_timeout_non_interruptible);
+
+int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+{
+ if (time_offset_ns >= 100 * USECOND)
+ poller_call();
+
+ return is_timeout_non_interruptible(start_ns, time_offset_ns);
+}
EXPORT_SYMBOL(is_timeout);
void ndelay(unsigned long nsecs)
{
uint64_t start = get_time_ns();
- while(!is_timeout(start, nsecs));
+ while(!is_timeout_non_interruptible(start, nsecs));
}
EXPORT_SYMBOL(ndelay);