[PATCH v1 5/6] iio: frequency: ad9523: Convert to use PI definition

Andy Shevchenko
2025-10-27T14:38:59Z

Convert to use PI definition instead of open coded value of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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..fab1671d9212 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_ULL(PI, 1000)) /
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_ULL(PI, 1000);
tmp = clamp(tmp, 0, 63);
reg &= ~AD9523_CLK_DIST_DIV_PHASE(~0);
reg |= AD9523_CLK_DIST_DIV_PHASE(tmp);
--
2.50.1