summaryrefslogtreecommitdiff
path: root/drivers/iio/frequency
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2019-05-17 16:37:11 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-05-18 09:40:37 +0100
commit0d698a538f8d4827c3209c44db57ca5a5945550e (patch)
tree98d0c4eccdaa170a7e8039593c68fa540ba0ed41 /drivers/iio/frequency
parenta2d2010d95cd7ffe3773aba6eaee35d54e332c25 (diff)
iio: ad9523-1: Improve reported VCO frequency accuracy
To improve the accuracy of the reported VCO frequency perform all multiplications before divisions. This reduces rounding errors and makes sure the reported rates are accurate down to the last digit. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/frequency')
-rw-r--r--drivers/iio/frequency/ad9523.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 9b9eee27176c..ceb1daceeb46 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -862,9 +862,11 @@ static int ad9523_setup(struct iio_dev *indio_dev)
if (ret < 0)
return ret;
- st->vco_freq = (pdata->vcxo_freq * (pdata->pll2_freq_doubler_en ? 2 : 1)
- / pdata->pll2_r2_div) * AD9523_PLL2_FB_NDIV(pdata->
- pll2_ndiv_a_cnt, pdata->pll2_ndiv_b_cnt);
+ st->vco_freq = div_u64((unsigned long long)pdata->vcxo_freq *
+ (pdata->pll2_freq_doubler_en ? 2 : 1) *
+ AD9523_PLL2_FB_NDIV(pdata->pll2_ndiv_a_cnt,
+ pdata->pll2_ndiv_b_cnt),
+ pdata->pll2_r2_div);
ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL,
AD9523_PLL2_VCO_CALIBRATE);