From 429b05a79a08eedc9fae2ae2b7cdce20615595ff Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Sun, 11 Dec 2022 19:17:09 +0900 Subject: [PATCH] drivers: counter: stm32_timer: remove counter_stm32_is_bit_mask() function Remove implementation of counter_stm32_is_bit_mask() and Use IS_BIT_MASK() macro. Signed-off-by: TOKITA Hiroshi --- drivers/counter/counter_ll_stm32_timer.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/counter/counter_ll_stm32_timer.c b/drivers/counter/counter_ll_stm32_timer.c index c3aa068b613..188c9847741 100644 --- a/drivers/counter/counter_ll_stm32_timer.c +++ b/drivers/counter/counter_ll_stm32_timer.c @@ -150,17 +150,11 @@ static int counter_stm32_get_value(const struct device *dev, uint32_t *ticks) return 0; } -/* Return true if value equals 2^n - 1 */ -static inline bool counter_stm32_is_bit_mask(uint32_t val) -{ - return !(val & (val + 1U)); -} - static uint32_t counter_stm32_ticks_add(uint32_t val1, uint32_t val2, uint32_t top) { uint32_t to_top; - if (likely(counter_stm32_is_bit_mask(top))) { + if (likely(IS_BIT_MASK(top))) { return (val1 + val2) & top; } @@ -171,7 +165,7 @@ static uint32_t counter_stm32_ticks_add(uint32_t val1, uint32_t val2, uint32_t t static uint32_t counter_stm32_ticks_sub(uint32_t val, uint32_t old, uint32_t top) { - if (likely(counter_stm32_is_bit_mask(top))) { + if (likely(IS_BIT_MASK(top))) { return (val - old) & top; }