]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: frequency: ad9832: simplify bitwise math
authorJoshua Crofts <joshua.crofts1@gmail.com>
Sun, 19 Apr 2026 18:36:23 +0000 (20:36 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 09:59:33 +0000 (10:59 +0100)
Refactor the ad9832_calc_freqreg by removing the redundant u64 casts
and 1L bitwise left shift and replacing the multiplication by a bit
shift, as multiplying integers by a power of two is identical to a
bitwise left shift.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/frequency/ad9832.c

index c0b7852f1c8426e1f8f49298e0e27a5e94628508..659821a1e2cb3bf9e66cb01ec34b98dada181948 100644 (file)
@@ -117,8 +117,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 << AD9832_FREQ_BITS;
+
        do_div(freqreg, mclk);
        return freqreg;
 }