diff options
author | Sean Anderson <seanga2@gmail.com> | 2020-10-07 14:37:44 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-10-22 09:54:53 -0400 |
commit | 8af7bb914f8b2238ea37faa8e59277ba4cb26d37 (patch) | |
tree | 8bb80517f8d547e0b845354e99375938f0f3fcbc /drivers/timer/riscv_timer.c | |
parent | aff60aba6c44770fab8f2694ae81bafde6d22998 (diff) |
timer: Return count from timer_ops.get_count
No timer drivers return an error from get_count. Instead of possibly
returning an error, just return the count directly.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/timer/riscv_timer.c')
-rw-r--r-- | drivers/timer/riscv_timer.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c index 449fcfcfd59..21ae1840571 100644 --- a/drivers/timer/riscv_timer.c +++ b/drivers/timer/riscv_timer.c @@ -16,22 +16,19 @@ #include <timer.h> #include <asm/csr.h> -static int riscv_timer_get_count(struct udevice *dev, u64 *count) +static u64 riscv_timer_get_count(struct udevice *dev) { - if (IS_ENABLED(CONFIG_64BIT)) { - *count = csr_read(CSR_TIME); - } else { - u32 hi, lo; + __maybe_unused u32 hi, lo; - do { - hi = csr_read(CSR_TIMEH); - lo = csr_read(CSR_TIME); - } while (hi != csr_read(CSR_TIMEH)); + if (IS_ENABLED(CONFIG_64BIT)) + return csr_read(CSR_TIME); - *count = ((u64)hi << 32) | lo; - } + do { + hi = csr_read(CSR_TIMEH); + lo = csr_read(CSR_TIME); + } while (hi != csr_read(CSR_TIMEH)); - return 0; + return ((u64)hi << 32) | lo; } static int riscv_timer_probe(struct udevice *dev) |