Re: [PATCH v3 2/2] iio: frequency: ad9832: simplify bitwise math
From: Andy Shevchenko
Date: Tue Apr 14 2026 - 05:44:32 EST
On Sat, Apr 11, 2026 at 02:35:12PM +0200, Joshua Crofts wrote:
> Refactor the ad9832_calc_freqreg by adding a BIT_ULL()
> macro instead of manual bit shifting for better
> readability.
"While at it, switch to u64 type for the local variable
that may hold big values."
...
> - unsigned long long freqreg = (u64)fout *
> - (u64)((u64)1L << AD9832_FREQ_BITS);
> + u64 freqreg = (u64)fout * BIT_ULL(AD9832_FREQ_BITS);
It can even be just like this:
u64 freqreg = fout * BIT_ULL(AD9832_FREQ_BITS);
if I understand the integer promotion for unsigned types here
and the * operator correctly.
--
With Best Regards,
Andy Shevchenko