Skip to contentSkip to conversation

iio: frequency: ad9832: cleanups

PATCH Superseded Joshua Crofts 2 participants 4 messages Apr 11

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 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

Joshua Crofts (2):
iio: frequency: ad9832: remove kernel.h proxy header.
iio: frequency: ad9832: simplify bitwise math

 drivers/staging/iio/frequency/ad9832.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 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.

---
v2:
- removed redundant bits.h header

 drivers/staging/iio/frequency/ad9832.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +1 -2
index b87ea1781b..8873a6d11e 100644
@@ -8,11 +8,10 @@
 #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>
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/2 iio: frequency: ad9832: simplify bitwise math

In reply to Joshua Crofts

Refactor the ad9832_calc_freqreg by adding a BIT_ULL() macro instead of manual bit shifting for better readability.

---
v2:
- changed ull to u64 type

 drivers/staging/iio/frequency/ad9832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -2
index 8873a6d11e..4221e51dc4 100644
@@ -112,8 +112,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)i;
+
 	do_div(freqreg, mclk);
 	return freqreg;
 }
Signature · 1 line
2.34.1
Reviewed-by on the v2 series
#3 lore raw
In reply to Joshua Crofts
Quoted 9 lines · 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

Quoted 6 lines

Joshua Crofts (2):
  iio: frequency: ad9832: remove kernel.h proxy header.
  iio: frequency: ad9832: simplify bitwise math

 drivers/staging/iio/frequency/ad9832.c | 7 +++----

 1 file changed, 3 insertions(+), 4 deletions(-)