From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3176C04AAF for ; Sat, 18 May 2019 08:41:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C480820872 for ; Sat, 18 May 2019 08:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbfERIl2 (ORCPT ); Sat, 18 May 2019 04:41:28 -0400 Received: from saturn.retrosnub.co.uk ([46.235.226.198]:44972 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbfERIl2 (ORCPT ); Sat, 18 May 2019 04:41:28 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) by saturn.retrosnub.co.uk (Postfix; Retrosnub mail submission) with ESMTPSA id 2C7E39E8317; Sat, 18 May 2019 09:41:25 +0100 (BST) Date: Sat, 18 May 2019 09:41:24 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: , Lars-Peter Clausen Subject: Re: [PATCH][RESEND] iio: ad9523-1: Improve reported VCO frequency accuracy Message-ID: <20190518094124.517568ca@archlinux> In-Reply-To: <20190517133711.21266-1-alexandru.ardelean@analog.com> References: <20190326132658.16724-1-alexandru.ardelean@analog.com> <20190517133711.21266-1-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Fri, 17 May 2019 16:37:11 +0300 Alexandru Ardelean wrote: > From: Lars-Peter Clausen > > 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 > Signed-off-by: Alexandru Ardelean Not sure how I missed this one the first time around! Thanks for the resend and applied to the togreg branch of iio.git. Thanks, Jonathan > --- > drivers/iio/frequency/ad9523.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c > index 246e38d76eff..541cb5975dd9 100644 > --- a/drivers/iio/frequency/ad9523.c > +++ b/drivers/iio/frequency/ad9523.c > @@ -1140,9 +1140,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);