From 21dc3f58e468d21a78cd63e5db23cdbded4da745 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Sun, 11 Dec 2022 19:18:47 +0900 Subject: [PATCH] drivers: counter: nrfx_rtc: Remove is_bit_mask() implementation Replace is_bit_mask() with IS_BIT_MASK() and remove the implementation. Signed-off-by: TOKITA Hiroshi --- drivers/counter/counter_nrfx_rtc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/counter/counter_nrfx_rtc.c b/drivers/counter/counter_nrfx_rtc.c index 38ff2807caa..3470cbfa03f 100644 --- a/drivers/counter/counter_nrfx_rtc.c +++ b/drivers/counter/counter_nrfx_rtc.c @@ -102,12 +102,6 @@ static int get_value(const struct device *dev, uint32_t *ticks) return 0; } -/* Return true if value equals 2^n - 1 */ -static inline bool is_bit_mask(uint32_t val) -{ - return !(val & (val + 1)); -} - /* Function calculates distance between to values assuming that one first * argument is in front and that values wrap. */ @@ -116,7 +110,7 @@ static uint32_t ticks_sub(const struct device *dev, uint32_t val, { if (IS_FIXED_TOP(dev)) { return (val - old) & COUNTER_MAX_TOP_VALUE; - } else if (likely(is_bit_mask(top))) { + } else if (likely(IS_BIT_MASK(top))) { return (val - old) & top; } @@ -146,7 +140,7 @@ static uint32_t ticks_add(const struct device *dev, uint32_t val1, ARG_UNUSED(top); return sum & COUNTER_MAX_TOP_VALUE; } - if (likely(is_bit_mask(top))) { + if (likely(IS_BIT_MASK(top))) { sum = sum & top; } else { sum = sum > top ? sum - (top + 1) : sum;