9
0
Fork 0

clock: make get_time_ns() safe to be called without clocksource

make it possible to call get_time_ns() before the clocksource
has been registered. Just return 0 in this case which is still
better than crashing the system.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-09-30 08:27:09 +02:00
parent 96cae61eba
commit 8af0569b7b
1 changed files with 3 additions and 0 deletions

View File

@ -44,6 +44,9 @@ uint64_t get_time_ns(void)
uint64_t cycle_now, cycle_delta;
uint64_t ns_offset;
if (!cs)
return 0;
/* read clocksource: */
cycle_now = cs->read() & cs->mask;