[PATCH 1/4] clock: Change cyc2ns return type to uint64_t

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

 



Using an uint32_t to count nanosec will overflow every ~4sec, this means
that if get_time_ns is not called often enough the time keeping will be
wrong. By changing the return type to uint64_t doesn't fix the underlying
overflow issue but it will take more than 500 years to happen and I think
it's safe to assume this won't be an issue.

Signed-off-by: Jules Maselbas <jmaselbas@xxxxxxxxx>
---
 include/clock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/clock.h b/include/clock.h
index d681bf630..e6197e7eb 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -17,7 +17,7 @@ struct clocksource {
 	int		(*init)(struct clocksource*);
 };
 
-static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
+static inline uint64_t cyc2ns(struct clocksource *cs, uint64_t cycles)
 {
         uint64_t ret = cycles;
         ret = (ret * cs->mult) >> cs->shift;
-- 
2.17.1



_______________________________________________
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