linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Deepak R Varma <mh12gx2825@gmail.com>
Cc: outreachy-kernel@googlegroups.com,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Daniel Baluta <daniel.baluta@gmail.com>,
	kieran.bingham@ideasonboard.com,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	linux-iio <linux-iio@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] staging: iio: adc: ad7192: get_filter_freq code optimization
Date: Mon, 23 Mar 2020 01:44:20 +0200	[thread overview]
Message-ID: <CAHp75VfC=y1mHW5=ghwdMMZYg=00_a5RB0Phz4j_vM77pehvMA@mail.gmail.com> (raw)
In-Reply-To: <dad3cdb5de76234cc460300c31aea6af671f81ad.1584904896.git.mh12gx2825@gmail.com>

On Sun, Mar 22, 2020 at 9:57 PM Deepak R Varma <mh12gx2825@gmail.com> wrote:
>
> Current implementation of the function ad7192_get_available_filter_freq
> repeats calculation of output data rate a few times. We can simplify
> these steps by refactoring out the calculation of fADC. This would also
> addresses the checkpatch warning of line exceeding 80 character.

I'm not sure you did an equivalent changes. I believe in the original
code precision is better. Consider low clock frequencies when 10 bit
right shift may hide some bits of the division.

Care to write a python script to check the precision between old and new code?

...

> -       /* Formulas for filter at page 25 of the datasheet */
> -       fadc = DIV_ROUND_CLOSEST(st->fclk,
> -                                AD7192_SINC4_FILTER * AD7192_MODE_RATE(st->mode));
> -       freq[0] = DIV_ROUND_CLOSEST(fadc * 240, 1024);
> +       fadc = DIV_ROUND_CLOSEST(st->fclk, AD7192_MODE_RATE(st->mode) * 1024);
>
> -       fadc = DIV_ROUND_CLOSEST(st->fclk,
> -                                AD7192_SINC3_FILTER * AD7192_MODE_RATE(st->mode));
> -       freq[1] = DIV_ROUND_CLOSEST(fadc * 240, 1024);
> -
> -       fadc = DIV_ROUND_CLOSEST(st->fclk, AD7192_MODE_RATE(st->mode));
> -       freq[2] = DIV_ROUND_CLOSEST(fadc * 230, 1024);
> -       freq[3] = DIV_ROUND_CLOSEST(fadc * 272, 1024);
> +       /* Formulas for filter at page 25 of the datasheet */
> +       freq[0] = DIV_ROUND_CLOSEST(fadc * 240, AD7192_SINC4_FILTER);
> +       freq[1] = DIV_ROUND_CLOSEST(fadc * 240, AD7192_SINC3_FILTER);
> +       freq[2] = fadc * 230;
> +       freq[3] = fadc * 272;


-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2020-03-22 23:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22 19:53 [PATCH v3 0/4] staging: iio: adc: General code reformatting / cleanup patchset Deepak R Varma
2020-03-22 19:54 ` [PATCH v3 1/4] staging: iio: adc: ad7192: Re-indent enum labels Deepak R Varma
2020-03-24  7:18   ` Ardelean, Alexandru
2020-03-26  8:19   ` Ardelean, Alexandru
2020-03-26  8:22     ` Ardelean, Alexandru
2020-03-22 19:55 ` [PATCH v3 2/4] staging: iio: adc: ad7192: Correct macro names from SYNC to SINC Deepak R Varma
2020-03-22 23:40   ` Andy Shevchenko
2020-03-23 17:50     ` DEEPAK VARMA
2020-03-26  8:20   ` Ardelean, Alexandru
2020-03-22 19:56 ` [PATCH v3 3/4] staging: iio: adc: ad7192: get_filter_freq code optimization Deepak R Varma
2020-03-22 23:44   ` Andy Shevchenko [this message]
2020-03-23  0:49     ` [Outreachy kernel] " Stefano Brivio
2020-03-23  9:28       ` Andy Shevchenko
2020-03-23 12:15         ` Stefano Brivio
2020-03-23 17:52           ` DEEPAK VARMA
2020-03-24  8:06             ` Ardelean, Alexandru
2020-03-25 17:38               ` DEEPAK VARMA
2020-03-25 19:37                 ` Andy Shevchenko
2020-03-25 19:59                 ` Stefano Brivio
2020-03-26  8:15                 ` Ardelean, Alexandru
2020-03-22 19:57 ` [PATCH v3 4/4] staging: iio: adc: ad7280a: Add comments to clarify stringified arguments Deepak R Varma
2020-03-24  8:07   ` Ardelean, Alexandru
2020-03-28 13:28     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHp75VfC=y1mHW5=ghwdMMZYg=00_a5RB0Phz4j_vM77pehvMA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=daniel.baluta@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=mh12gx2825@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).