diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/delay_timer/delay_timer.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/delay_timer/delay_timer.c b/drivers/delay_timer/delay_timer.c index c9f84d77..587724eb 100644 --- a/drivers/delay_timer/delay_timer.c +++ b/drivers/delay_timer/delay_timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,7 +12,7 @@ /*********************************************************** * The delay timer implementation ***********************************************************/ -static const timer_ops_t *ops; +static const timer_ops_t *timer_ops; /*********************************************************** * Delay for the given number of microseconds. The driver must @@ -20,26 +20,27 @@ static const timer_ops_t *ops; ***********************************************************/ void udelay(uint32_t usec) { - assert(ops != NULL && - (ops->clk_mult != 0) && - (ops->clk_div != 0) && - (ops->get_timer_value != NULL)); + assert(timer_ops != NULL && + (timer_ops->clk_mult != 0) && + (timer_ops->clk_div != 0) && + (timer_ops->get_timer_value != NULL)); uint32_t start, delta, total_delta; - assert(usec < UINT32_MAX / ops->clk_div); + assert(usec < UINT32_MAX / timer_ops->clk_div); - start = ops->get_timer_value(); + start = timer_ops->get_timer_value(); /* Add an extra tick to avoid delaying less than requested. */ - total_delta = div_round_up(usec * ops->clk_div, ops->clk_mult) + 1; + total_delta = + div_round_up(usec * timer_ops->clk_div, timer_ops->clk_mult) + 1; do { /* * If the timer value wraps around, the subtraction will * overflow and it will still give the correct result. */ - delta = start - ops->get_timer_value(); /* Decreasing counter */ + delta = start - timer_ops->get_timer_value(); /* Decreasing counter */ } while (delta < total_delta); } @@ -64,5 +65,5 @@ void timer_init(const timer_ops_t *ops_ptr) (ops_ptr->clk_div != 0) && (ops_ptr->get_timer_value != NULL)); - ops = ops_ptr; + timer_ops = ops_ptr; } |