Skip to content

Commit 5b382bf

Browse files
cjd8jic23
authored andcommitted
iio: frequency: ad9832: simplify bitwise math
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>
1 parent c0536d6 commit 5b382bf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/staging/iio/frequency/ad9832.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ struct ad9832_state {
117117

118118
static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
119119
{
120-
unsigned long long freqreg = (u64)fout *
121-
(u64)((u64)1L << AD9832_FREQ_BITS);
120+
u64 freqreg = (u64)fout << AD9832_FREQ_BITS;
121+
122122
do_div(freqreg, mclk);
123123
return freqreg;
124124
}

0 commit comments

Comments
 (0)