[PATCH v2 5/6] iio: frequency: ad9523: Convert to use PI definition
From: Andy Shevchenko
Date: Fri Nov 07 2025 - 15:10:17 EST
Convert to use PI definition instead of open coded value of it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/iio/frequency/ad9523.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 63c485e9e44c..781e0ada75d9 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/module.h>
#include <linux/delay.h>
+#include <linux/units.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -652,7 +653,7 @@ static int ad9523_read_raw(struct iio_dev *indio_dev,
AD9523_CLK_DIST_DIV_REV(ret);
return IIO_VAL_INT;
case IIO_CHAN_INFO_PHASE:
- code = (AD9523_CLK_DIST_DIV_PHASE_REV(ret) * 3141592) /
+ code = (AD9523_CLK_DIST_DIV_PHASE_REV(ret) * DIV_ROUND_UP(PI, 100)) /
AD9523_CLK_DIST_DIV_REV(ret);
*val = code / 1000000;
*val2 = code % 1000000;
@@ -701,7 +702,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_PHASE:
code = val * 1000000 + val2 % 1000000;
- tmp = (code * AD9523_CLK_DIST_DIV_REV(ret)) / 3141592;
+ tmp = (code * AD9523_CLK_DIST_DIV_REV(reg)) / DIV_ROUND_UP(PI, 100);
tmp = clamp(tmp, 0, 63);
reg &= ~AD9523_CLK_DIST_DIV_PHASE(~0);
reg |= AD9523_CLK_DIST_DIV_PHASE(tmp);
--
2.50.1