* [PATCH v6 0/2] iio: frequency: ad9832: cleanups
@ 2026-04-17 10:16 Joshua Crofts
2026-04-17 10:16 ` [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header Joshua Crofts
2026-04-17 10:16 ` [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
0 siblings, 2 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-04-17 10:16 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, gregkh
Cc: dlechner, nuno.sa, andy, linux-iio, linux-staging, linux-kernel,
Joshua Crofts
This series cleans up issues in the AD9832 driver, including proxy
header removal and bit math simplification.
v2:
- PATCH 1: removed redundant bits.h include as it is implied in
bitops.h
- PATCH 2: changed ull to u64 type
v3:
- PATCH 2: remove rogue vim typo
v4:
- PATCH 1: removed slab.h based on IWYU recommendation, header
reordering
v5:
- PATCH 1: commit message stylistic changes
v6:
- PATCH 1: add additional headers per kernel.h removal, commit message
edit
- PATCH 2: commit message edit
Joshua Crofts (2):
iio: frequency: ad9832: remove kernel.h proxy header
iio: frequency: ad9832: simplify bitwise math
drivers/staging/iio/frequency/ad9832.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header
2026-04-17 10:16 [PATCH v6 0/2] iio: frequency: ad9832: cleanups Joshua Crofts
@ 2026-04-17 10:16 ` Joshua Crofts
2026-04-17 17:50 ` Andy Shevchenko
2026-04-17 10:16 ` [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
1 sibling, 1 reply; 7+ messages in thread
From: Joshua Crofts @ 2026-04-17 10:16 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, gregkh
Cc: dlechner, nuno.sa, andy, linux-iio, linux-staging, linux-kernel,
Joshua Crofts, Andy Shevchenko
Remove kernel.h proxy header and add replacement headers (array_size,
dev_printk.h, kstrtox, mod_devicetable, mutex, types, asm/byteorder) to
maintain atomicity. Moved asm/div64.h header below generic <linux/*>
headers. Additionally, add bitops.h for BIT_ULL() macro.
Audited using the include-what-you-use tool.
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>
---
drivers/staging/iio/frequency/ad9832.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index b87ea1781b..c0b7852f1c 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -5,21 +5,25 @@
* Copyright 2011 Analog Devices Inc.
*/
-#include <asm/div64.h>
-
+#include <linux/array_size.h>
#include <linux/bitfield.h>
-#include <linux/bits.h>
+#include <linux/bitops.h>
#include <linux/clk.h>
-#include <linux/device.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
-#include <linux/kernel.h>
+#include <linux/kstrtox.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
-#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
+#include <linux/types.h>
#include <linux/unaligned.h>
+#include <asm/byteorder.h>
+#include <asm/div64.h>
+
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math
2026-04-17 10:16 [PATCH v6 0/2] iio: frequency: ad9832: cleanups Joshua Crofts
2026-04-17 10:16 ` [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header Joshua Crofts
@ 2026-04-17 10:16 ` Joshua Crofts
2026-04-19 16:52 ` Jonathan Cameron
1 sibling, 1 reply; 7+ messages in thread
From: Joshua Crofts @ 2026-04-17 10:16 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 adding a BIT_ULL() macro instead of
manual bit shifting for better readability.
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>
---
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..6ce9651542 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 * BIT_ULL(AD9832_FREQ_BITS);
+
do_div(freqreg, mclk);
return freqreg;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header
2026-04-17 10:16 ` [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header Joshua Crofts
@ 2026-04-17 17:50 ` Andy Shevchenko
2026-04-19 16:53 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-04-17 17:50 UTC (permalink / raw)
To: Joshua Crofts
Cc: lars, Michael.Hennerich, jic23, gregkh, dlechner, nuno.sa, andy,
linux-iio, linux-staging, linux-kernel
On Fri, Apr 17, 2026 at 10:16:22AM +0000, Joshua Crofts wrote:
> Remove kernel.h proxy header and add replacement headers (array_size,
> dev_printk.h, kstrtox, mod_devicetable, mutex, types, asm/byteorder) to
I guess it's better to add .h to all of them.
No need to resend for that. Perhaps Jonathan tweaks it.
> maintain atomicity. Moved asm/div64.h header below generic <linux/*>
> headers. Additionally, add bitops.h for BIT_ULL() macro.
>
> Audited using the include-what-you-use tool.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math
2026-04-17 10:16 ` [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
@ 2026-04-19 16:52 ` Jonathan Cameron
2026-04-19 17:19 ` Joshua Crofts
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2026-04-19 16:52 UTC (permalink / raw)
To: Joshua Crofts
Cc: lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
linux-iio, linux-staging, linux-kernel, Andy Shevchenko
On Fri, 17 Apr 2026 10:16:23 +0000
Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> 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>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> ---
> 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..6ce9651542 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 * BIT_ULL(AD9832_FREQ_BITS);
https://sashiko.dev/#/patchset/20260417101623.1281-1-joshua.crofts1%40gmail.com
So does this actually improve readability? Sashiko had fun with this one and
I'm somewhat inclined to agree with it. The suggestion it made was that
the following was more readable still and avoided oddity of using BIT_ULL as
a multiplier.
u64 freqreg = (u64)fout << AD9832_FREQ_BITS;
> +
> do_div(freqreg, mclk);
> return freqreg;
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header
2026-04-17 17:50 ` Andy Shevchenko
@ 2026-04-19 16:53 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2026-04-19 16:53 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Joshua Crofts, lars, Michael.Hennerich, gregkh, dlechner, nuno.sa,
andy, linux-iio, linux-staging, linux-kernel
On Fri, 17 Apr 2026 20:50:05 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Apr 17, 2026 at 10:16:22AM +0000, Joshua Crofts wrote:
> > Remove kernel.h proxy header and add replacement headers (array_size,
> > dev_printk.h, kstrtox, mod_devicetable, mutex, types, asm/byteorder) to
>
> I guess it's better to add .h to all of them.
> No need to resend for that. Perhaps Jonathan tweaks it.
>
> > maintain atomicity. Moved asm/div64.h header below generic <linux/*>
> > headers. Additionally, add bitops.h for BIT_ULL() macro.
> >
> > Audited using the include-what-you-use tool.
>
Tidied up. The Sashiko stuff disagreed a bit with one or two choices, but
nothing that I think warrants a change to this.
So applied this patch
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math
2026-04-19 16:52 ` Jonathan Cameron
@ 2026-04-19 17:19 ` Joshua Crofts
0 siblings, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-04-19 17:19 UTC (permalink / raw)
To: Jonathan Cameron
Cc: lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
linux-iio, linux-staging, linux-kernel, Andy Shevchenko
On Sun, 19 Apr 2026 at 18:52, Jonathan Cameron <jic23@kernel.org> wrote:
> > - unsigned long long freqreg = (u64)fout *
> > - (u64)((u64)1L << AD9832_FREQ_BITS);
> > + u64 freqreg = (u64)fout * BIT_ULL(AD9832_FREQ_BITS);
> https://sashiko.dev/#/patchset/20260417101623.1281-1-joshua.crofts1%40gmail.com
>
> So does this actually improve readability? Sashiko had fun with this one and
> I'm somewhat inclined to agree with it. The suggestion it made was that
> the following was more readable still and avoided oddity of using BIT_ULL as
> a multiplier.
>
> u64 freqreg = (u64)fout << AD9832_FREQ_BITS;
Fair enough, the suggestion seems valid. IMO my initial patch did improve the
readability as it removed two u64 casts in the expression, but sure, I'll send a
follow up patch.
Thanks for the reviews on the other patches, these are my first ever ones
that I've submitted.
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-04-19 17:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 10:16 [PATCH v6 0/2] iio: frequency: ad9832: cleanups Joshua Crofts
2026-04-17 10:16 ` [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header Joshua Crofts
2026-04-17 17:50 ` Andy Shevchenko
2026-04-19 16:53 ` Jonathan Cameron
2026-04-17 10:16 ` [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
2026-04-19 16:52 ` Jonathan Cameron
2026-04-19 17:19 ` Joshua Crofts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox