[PATCH 2/4] clock: make get_time_ns() safe to be called without clocksource

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 common/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/clock.c b/common/clock.c
index 2dae9ff..76ce881 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -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;
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux