iio: frequency: ad9832: cleanups
Subsystems (4)
v5 cover iio: frequency: ad9832: cleanups
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
Joshua Crofts (2):
iio: frequency: ad9832: remove kernel.h proxy header
iio: frequency: ad9832: simplify bitwise math
drivers/staging/iio/frequency/ad9832.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
Signature · 1 line
2.47.3
PATCH v5 1/2 iio: frequency: ad9832: remove kernel.h proxy header
Remove kernel.h proxy header and add bitops.h for better dependency control and code clarity. Also removed slab.h and moved asm header below generic <linux/*> headers.
Audited using include-what-you-use.
--- drivers/staging/iio/frequency/ad9832.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/iio/frequency/ad9832.c +3 -5
@@ -5,21 +5,19 @@* Copyright 2011 Analog Devices Inc. */ -#include <asm/div64.h> -#include <linux/bitfield.h> -#include <linux/bits.h> +#include <linux/bitops.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/err.h> -#include <linux/kernel.h> #include <linux/module.h> #include <linux/regulator/consumer.h> -#include <linux/slab.h> #include <linux/spi/spi.h> #include <linux/sysfs.h> #include <linux/unaligned.h> +#include <asm/div64.h> +#include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
Signature · 1 line
2.47.3
Re: [PATCH v5 1/2] iio: frequency: ad9832: remove kernel.h proxy header
On Thu, Apr 16, 2026 at 06:51:17AM +0000, Joshua Crofts wrote:
Sorry that I missed some key points in the previous reviews (see below). v6 is needed.
...
Quoted 4 lines
Remove
kernel.hproxy header and addbitops.hfor
better dependency control and code clarity. Also
removedslab.hand moved asm header below generic
<linux/*> headers.
The comment uses too short lines (50), use up to ~72 characters per line, please.
Quoted 1 line
Audited using include-what-you-use.
While I gave a tag, it still seems need an improvement, id est there are missing headers:
array_size.hdev_printk.hkstrtox.hmod_devicetable.hmutex.htypes.h
asm/byteorder.h
and unneeded one(s):device.h
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 1/2] iio: frequency: ad9832: remove kernel.h proxy header
Quoted 10 lines · Andy Shevchenko
While I gave a tag, it still seems need an improvement, id est there are missing headers:
array_size.hdev_printk.hkstrtox.hmod_devicetable.hmutex.htypes.h
Quoted 4 lines
asm/byteorder.hand unneeded one(s):
device.h
Adding the headers above is fine, but removing device.h even if there are things like struct device_attribute in the code? I know linux/iio/iio.h includes device.h but I thought that we're trying to eliminate these "includes in includes" unless they're trivial (like linux/bits.h in linux/bitops.h).
Signature · 3 lines
Kind regards CJD
Re: [PATCH v5 1/2] iio: frequency: ad9832: remove kernel.h proxy header
Quoted 12 lines · Joshua Crofts
Quoted 10 lines · Andy Shevchenko
While I gave a tag, it still seems need an improvement, id est there are missing headers:
array_size.hdev_printk.hkstrtox.hmod_devicetable.hmutex.htypes.h
Quoted 7 lines
Quoted 4 lines
asm/byteorder.hand unneeded one(s):
device.hAdding the headers above is fine, but removing
device.heven if there are things like structdevice_attributein the code?
I don't see it's in use. The pointer to it yes, but it's a huge difference. https://en.wikipedia.org/wiki/Opaque_pointer
Quoted 3 lines
I know
linux/iio/iio.hincludesdevice.hbut I thought that we're trying to eliminate these "includes in includes" unless they're trivial (likelinux/bits.hinlinux/bitops.h).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 1/2] iio: frequency: ad9832: remove kernel.h proxy header
Quoted 2 lines · Andy Shevchenko
I don't see it's in use. The pointer to it yes, but it's a huge difference. https://en.wikipedia.org/wiki/Opaque_pointer
My bad, that was an oversight on my part. Thanks for the clarification. I'll send the updated patch soon.
Signature · 3 lines
Kind regards CJD
PATCH v5 2/2 iio: frequency: ad9832: simplify bitwise math
In reply to Joshua CroftsRefactor the ad9832_calc_freqreg by adding a BIT_ULL() macro instead of manual bit shifting for better readability.
--- drivers/staging/iio/frequency/ad9832.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -2
@@ -111,8 +111,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; }
Signature · 1 line
2.47.3
Re: [PATCH v5 2/2] iio: frequency: ad9832: simplify bitwise math
Quoted 3 lines · Joshua Crofts
Refactor the
ad9832_calc_freqregby adding aBIT_ULL()macro instead of manual bit shifting for better readability.
Code is okay, just make lines wider in the commit message (~72 characters).
Signature · 2 lines
With Best Regards, Andy Shevchenko