Commit 21dc3f58 authored by TOKITA Hiroshi's avatar TOKITA Hiroshi Committed by Carles Cufi
Browse files

drivers: counter: nrfx_rtc: Remove is_bit_mask() implementation



Replace is_bit_mask() with IS_BIT_MASK() and remove the implementation.

Signed-off-by: default avatarTOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
parent 429b05a7
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -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;