* [PATCH v7] iio: frequency: ad9832: simplify bitwise math
@ 2026-04-19 18:36 Joshua Crofts
2026-04-28 6:40 ` Joshua Crofts
0 siblings, 1 reply; 3+ messages in thread
From: Joshua Crofts @ 2026-04-19 18:36 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, gregkh
Cc: dlechner, nuno.sa, andy, linux-iio, linux-staging, linux-kernel,
Joshua Crofts, Andy Shevchenko
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>
---
v7:
- replaced multiplication with bitwise left shift
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 c0b7852f1c..659821a1e2 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v7] iio: frequency: ad9832: simplify bitwise math
2026-04-19 18:36 [PATCH v7] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
@ 2026-04-28 6:40 ` Joshua Crofts
2026-04-28 18:04 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Joshua Crofts @ 2026-04-28 6:40 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, gregkh
Cc: dlechner, nuno.sa, andy, linux-iio, linux-staging, linux-kernel,
Andy Shevchenko
On Sun, 19 Apr 2026 at 20:36, Joshua Crofts <joshua.crofts1@gmail.com> wrote:
>
> 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.
FYI.
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v7] iio: frequency: ad9832: simplify bitwise math
2026-04-28 6:40 ` Joshua Crofts
@ 2026-04-28 18:04 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-04-28 18:04 UTC (permalink / raw)
To: Joshua Crofts
Cc: lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
linux-iio, linux-staging, linux-kernel, Andy Shevchenko
On Tue, 28 Apr 2026 08:40:03 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> On Sun, 19 Apr 2026 at 20:36, Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> >
> > 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.
>
> FYI.
>
I was letting this one sit a while as we had a lot of discussion on earlier
versions. Ah well, I guess everyone is happy now.
Applied!
J
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-28 18:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-19 18:36 [PATCH v7] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
2026-04-28 6:40 ` Joshua Crofts
2026-04-28 18:04 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox