From: Jonathan Cameron <jic23@kernel.org>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
gregkh@linuxfoundation.org, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math
Date: Sun, 19 Apr 2026 17:52:02 +0100 [thread overview]
Message-ID: <20260419175202.7f0cec54@jic23-huawei> (raw)
In-Reply-To: <20260417101623.1281-3-joshua.crofts1@gmail.com>
On Fri, 17 Apr 2026 10:16:23 +0000
Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> Refactor the ad9832_calc_freqreg by adding a BIT_ULL() macro instead of
> manual bit shifting for better readability.
>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> ---
> drivers/staging/iio/frequency/ad9832.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index c0b7852f1c..6ce9651542 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -117,8 +117,8 @@ struct ad9832_state {
>
> static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
> {
> - unsigned long long freqreg = (u64)fout *
> - (u64)((u64)1L << AD9832_FREQ_BITS);
> + u64 freqreg = (u64)fout * BIT_ULL(AD9832_FREQ_BITS);
https://sashiko.dev/#/patchset/20260417101623.1281-1-joshua.crofts1%40gmail.com
So does this actually improve readability? Sashiko had fun with this one and
I'm somewhat inclined to agree with it. The suggestion it made was that
the following was more readable still and avoided oddity of using BIT_ULL as
a multiplier.
u64 freqreg = (u64)fout << AD9832_FREQ_BITS;
> +
> do_div(freqreg, mclk);
> return freqreg;
> }
next prev parent reply other threads:[~2026-04-19 16:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 10:16 [PATCH v6 0/2] iio: frequency: ad9832: cleanups Joshua Crofts
2026-04-17 10:16 ` [PATCH v6 1/2] iio: frequency: ad9832: remove kernel.h proxy header Joshua Crofts
2026-04-17 17:50 ` Andy Shevchenko
2026-04-19 16:53 ` Jonathan Cameron
2026-04-17 10:16 ` [PATCH v6 2/2] iio: frequency: ad9832: simplify bitwise math Joshua Crofts
2026-04-19 16:52 ` Jonathan Cameron [this message]
2026-04-19 17:19 ` Joshua Crofts
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=20260419175202.7f0cec54@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=joshua.crofts1@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nuno.sa@analog.com \
/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