[RESEND PATCH v2 2/2] iio: frequency: ad9832: simplify bitwise math

Joshua Crofts
2026-04-11T08:59:20Z

Refactor the ad9832_calc_freqreg by adding a BIT_ULL()
macro instead of manual bit shifting for better
readability.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
v2:
- changed ull to u64 type

drivers/staging/iio/frequency/ad9832.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 8873a6d11e..4221e51dc4 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -112,8 +112,8 @@ struct ad9832_state {

static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
{
- unsigned long long freqreg = (u64)fout *
- (u64)((u64)1L << AD9832_FREQ_BITS);
+ u64 freqreg = (u64)fout * BIT_ULL(AD9832_FREQ_BITS)i;
+
do_div(freqreg, mclk);
return freqreg;
}
--
2.34.1