From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: "Neil Armstrong" <neil.armstrong@linaro.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: add driver for the MAX34417 Four-Channel High Dynamic Range Power Accumulator
Date: Thu, 24 Sep 2026 17:20:07 +0300 [thread overview]
Message-ID: <arUxl7QeiEzFlI7O@ashevche-desk.local> (raw)
In-Reply-To: <20260924095457.00006ed6@gmail.com>
On Thu, Sep 24, 2026 at 09:54:57AM +0200, Joshua Crofts wrote:
> On Wed, 23 Sep 2026 21:10:23 +0200
> Neil Armstrong <neil.armstrong@linaro.org> wrote:
Joshua, below also something to you to pay attention to on top of the good
parts you covered already.
...
> > +/**
> > + * struct max34417_data - max34417 specific data.
> > + * @regmap: device register map.
> > + * @dev: max34417 device.
> > + * @lock: lock for protecting access to device hardware registers, mostly
>
> Nit-picking, but... Device, MAX34417, Lock.
Generally speaking it should be consistent with whatever style is being chosen.
If we go with the first capitalized letter, then yes, otherwise below should go
to small first letter. In any case MAX part number should be capitalized (or
someone might think of it as struct max34417).
> > + * for reading common accumulator count and control register.
> > + * @input_correction: Correction based on the Rsense value from channel nodes.
> > + * @input_label: Channel label from channel nodes.
> > + */
...
> > +static int max34417_read_voltage(struct max34417_data *max34417,
> > + const struct iio_chan_spec *chan, int *val)
> > +{
> > + uint16_t voltage;
> > + uint8_t buf[3];
uXX types, please. Everywhere.
> > + int rc;
> > +
> > + guard(mutex)(&max34417->lock);
> > +
> > + rc = max34417_accumulator_update(max34417);
> > + if (rc)
> > + return rc;
> > +
> > + rc = regmap_noinc_read(max34417->regmap, chan->address, &buf, 3);
sizeof()
> > + if (rc)
> > + return rc;
> > +
> > + voltage = buf[2] | ((uint64_t)buf[1] << 8);
> > + voltage >>= 2;
Not sure what is in the buf[0], but verbatim the above is get_unaligned_le16().
> > + *val = voltage;
> > +
> > + return IIO_VAL_INT;
> > +}
...
> > + power = buf[7];
> > + power |= ((uint64_t)buf[6] << 8UL);
> > + power |= ((uint64_t)buf[5] << 16UL);
> > + power |= ((uint64_t)buf[4] << 24UL);
> > + power |= ((uint64_t)buf[3] << 32UL);
> > + power |= ((uint64_t)buf[2] << 40UL);
> > + power |= ((uint64_t)buf[1] << 48UL);
get_unaligned_be64() / be64_to_cpu().
...
> > + fwnode_property_read_string(node, "label", &max34417->input_label[index]);
> > + if (fwnode_property_read_u32(node, "maxim,rsense-val-micro-ohms", &rsense))
> > + rsense = MAX34417_DEFAULT_RSENSE;
What if the property is there, but some issue has happened?
We have an idiomatic
if (_property_present()) {
rc = _property_read();
if (rc)
return ...rc...;
...
} else {
...apply default...
}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-09-24 14:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 19:10 [PATCH 0/2] iio: adc: add support for the MAX34417 Four-Channel High Dynamic Range Power Accumulator Neil Armstrong
2026-09-23 19:10 ` [PATCH 1/2] dt-bindings: iio: add: document " Neil Armstrong
2026-09-23 19:18 ` sashiko-bot
2026-09-24 7:14 ` Neil Armstrong
2026-09-23 19:10 ` [PATCH 2/2] iio: adc: add driver for " Neil Armstrong
2026-09-23 19:19 ` sashiko-bot
2026-09-24 7:16 ` Neil Armstrong
2026-09-24 7:54 ` Joshua Crofts
2026-09-24 14:20 ` Andy Shevchenko [this message]
2026-09-24 15:12 ` Joshua Crofts
2026-09-24 15:23 ` Neil Armstrong
2026-09-24 15:25 ` Neil Armstrong
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=arUxl7QeiEzFlI7O@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@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