mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-26 06:30:39 +00:00
d0a9b82b75
When fixing sandbox test for regmap_read_poll_timeout(), the
sandbox_timer_add_offset was introduced but only defined in sandbox code
thus generating warnings when used out of sandbox :
include/regmap.h:289:2: note: in expansion of macro 'regmap_read_poll_timeout_test'
regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/meson_spifc.c:169:8: note: in expansion of macro 'regmap_read_poll_timeout'
ret = regmap_read_poll_timeout(spifc->regmap, REG_SLAVE, data,
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/meson_spifc.c: In function 'meson_spifc_txrx':
include/regmap.h:277:4: warning: implicit declaration of function 'sandbox_timer_add_offset' [-Wimplicit-function-declaration]
This fix adds a timer_test_add_offset() only defined in sandbox, and
renames the previous sandbox_timer_add_offset() to it.
Cc: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
Fixes: df9cf1cc08
("test: dm: regmap: Fix the long test delay")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
63 lines
1.7 KiB
C
63 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
#ifndef _TIME_H
|
|
#define _TIME_H
|
|
|
|
#include <linux/typecheck.h>
|
|
|
|
unsigned long get_timer(unsigned long base);
|
|
|
|
/*
|
|
* Return the current value of a monotonically increasing microsecond timer.
|
|
* Granularity may be larger than 1us if hardware does not support this.
|
|
*/
|
|
unsigned long timer_get_us(void);
|
|
|
|
/*
|
|
* timer_test_add_offset()
|
|
*
|
|
* Allow tests to add to the time reported through lib/time.c functions
|
|
* offset: number of milliseconds to advance the system time
|
|
*/
|
|
void timer_test_add_offset(unsigned long offset);
|
|
|
|
/*
|
|
* These inlines deal with timer wrapping correctly. You are
|
|
* strongly encouraged to use them
|
|
* 1. Because people otherwise forget
|
|
* 2. Because if the timer wrap changes in future you won't have to
|
|
* alter your driver code.
|
|
*
|
|
* time_after(a,b) returns true if the time a is after time b.
|
|
*
|
|
* Do this with "<0" and ">=0" to only test the sign of the result. A
|
|
* good compiler would generate better code (and a really good compiler
|
|
* wouldn't care). Gcc is currently neither.
|
|
*/
|
|
#define time_after(a,b) \
|
|
(typecheck(unsigned long, a) && \
|
|
typecheck(unsigned long, b) && \
|
|
((long)((b) - (a)) < 0))
|
|
#define time_before(a,b) time_after(b,a)
|
|
|
|
#define time_after_eq(a,b) \
|
|
(typecheck(unsigned long, a) && \
|
|
typecheck(unsigned long, b) && \
|
|
((long)((a) - (b)) >= 0))
|
|
#define time_before_eq(a,b) time_after_eq(b,a)
|
|
|
|
/*
|
|
* Calculate whether a is in the range of [b, c].
|
|
*/
|
|
#define time_in_range(a,b,c) \
|
|
(time_after_eq(a,b) && \
|
|
time_before_eq(a,c))
|
|
|
|
/*
|
|
* Calculate whether a is in the range of [b, c).
|
|
*/
|
|
#define time_in_range_open(a,b,c) \
|
|
(time_after_eq(a,b) && \
|
|
time_before(a,c))
|
|
|
|
#endif /* _TIME_H */
|