From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Paller, Kim Seer" <KimSeer.Paller@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
"Sa, Nuno" <Nuno.Sa@analog.com>,
Andy Shevchenko <andy@kernel.org>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux <linux@analog.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] iio: dac: ad3530r: Add support for AD3532R/AD3532
Date: Fri, 26 Jun 2026 13:11:20 +0300 [thread overview]
Message-ID: <aj5QSEVfazR-mTSA@ashevche-desk.local> (raw)
In-Reply-To: <PH0PR03MB7141482F87D8416DBDB90136F9EC2@PH0PR03MB7141.namprd03.prod.outlook.com>
On Thu, Jun 25, 2026 at 10:06:26AM +0000, Paller, Kim Seer wrote:
> > From: Andy Shevchenko <andriy.shevchenko@intel.com>
> > Sent: Monday, June 15, 2026 6:06 PM
> > On Mon, Jun 15, 2026 at 02:20:18PM +0800, Kim Seer Paller wrote:
...
> > > + local_ch = chan->channel % AD3530R_CH_PER_BANK;
> >
> > > + reg = (chan->channel < AD3530R_CH_PER_BANK ?
> > AD3532R_OUTPUT_OPERATING_MODE_0 :
> > > + AD3532R_OUTPUT_OPERATING_MODE_2) +
> > > + local_ch / AD3530R_CH_PER_REG;
> >
> > This is unreadable. Can you refactor it?
>
> Would this be clearer?
>
> unsigned int bank_base;
>
> local_ch = chan->channel % AD3530R_CH_PER_BANK;
> bank_base = chan->channel < AD3530R_CH_PER_BANK ?
> AD3532R_OUTPUT_OPERATING_MODE_0 : AD3532R_OUTPUT_OPERATING_MODE_2;
> reg = bank_base + local_ch / AD3530R_CH_PER_REG;
No. Too much voodoo arithmetics and comparisons.
> > > + mask = AD3530R_OP_MODE_CHAN_MSK(local_ch %
> > AD3530R_CH_PER_REG);
Including this one.
I would expect to see maybe two more variables to hold
local_ch % BANK and local_ch / BANK.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-06-26 10:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 6:20 [PATCH v2 0/4] Add support for AD3532R/AD3532 Kim Seer Paller
2026-06-15 6:20 ` [PATCH v2 1/4] iio: dac: ad3530r: Refactor setup to table-driven register bank approach Kim Seer Paller
2026-06-15 6:30 ` sashiko-bot
2026-06-15 7:22 ` Joshua Crofts
2026-06-15 10:08 ` Andy Shevchenko
2026-06-26 8:44 ` Paller, Kim Seer
2026-06-26 10:12 ` Andy Shevchenko
2026-06-21 16:49 ` Jonathan Cameron
2026-06-15 6:20 ` [PATCH v2 2/4] iio: ABI: add DAC 10kohm_to_gnd powerdown mode Kim Seer Paller
2026-06-15 6:32 ` sashiko-bot
2026-06-15 6:20 ` [PATCH v2 3/4] dt-bindings: iio: dac: add support for AD3532R/AD3532 Kim Seer Paller
2026-06-15 6:33 ` sashiko-bot
2026-06-15 6:20 ` [PATCH v2 4/4] iio: dac: ad3530r: Add " Kim Seer Paller
2026-06-15 6:33 ` sashiko-bot
2026-06-15 10:05 ` Andy Shevchenko
2026-06-21 16:45 ` Jonathan Cameron
2026-06-25 10:07 ` Paller, Kim Seer
2026-06-25 14:22 ` Andy Shevchenko
2026-06-25 10:06 ` Paller, Kim Seer
2026-06-26 10:11 ` Andy Shevchenko [this message]
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=aj5QSEVfazR-mTSA@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=KimSeer.Paller@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=Nuno.Sa@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=robh@kernel.org \
/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