@@ -17,6 +17,17 @@ unsigned long get_timer(unsigned long base);
unsigned long timer_get_us(void);
uint64_t get_timer_us(uint64_t base);
+/**
+ * get_timer_us_long() - Get the number of elapsed microseconds
+ *
+ * This uses 32-bit arithmetic on 32-bit machines, which is enough to handle
+ * delays of over an hour.
+ *
+ *@base: Base time to consider
+ *@return elapsed time since @base
+ */
+unsigned long get_timer_us_long(unsigned long base);
+
/*
* timer_test_add_offset()
*
@@ -152,6 +152,11 @@ uint64_t __weak get_timer_us(uint64_t base)
return tick_to_time_us(get_ticks()) - base;
}
+unsigned long __weak get_timer_us_long(unsigned long base)
+{
+ return timer_get_us() - base;
+}
+
unsigned long __weak notrace timer_get_us(void)
{
return tick_to_time(get_ticks() * 1000);
The current get_timer_us() uses 64-bit arithmetic. When implementing microsecond-level timeouts, 32-bits is plenty. Add a new function to support this. Signed-off-by: Simon Glass <sjg at chromium.org> --- include/time.h | 11 +++++++++++ lib/time.c | 5 +++++ 2 files changed, 16 insertions(+)