From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: "Esteban Blanc" <eblanc@baylibre.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 2/6] iio: adc: ad4030: add driver for ad4030-24
Date: Mon, 23 Dec 2024 12:04:19 +0000 [thread overview]
Message-ID: <20241223120419.757eadfb@jic23-huawei> (raw)
In-Reply-To: <Z2eqOSN2Uk8SfTq1@debian-BULLSEYE-live-builder-AMD64>
Just commenting on one particular bit feedback. Makes sure to address the
rest!
> > +
> > +static int ad4030_get_chan_calibscale(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan,
> > + int *val,
> > + int *val2)
> > +{
> > + struct ad4030_state *st = iio_priv(indio_dev);
> > + u16 gain;
> > + int ret;
> > +
> > + ret = regmap_bulk_read(st->regmap, AD4030_REG_GAIN_CHAN(chan->address),
> > + st->rx_data.raw, AD4030_REG_GAIN_BYTES_NB);
> > + if (ret)
> > + return ret;
> > +
> > + gain = get_unaligned_be16(st->rx_data.raw);
> My impression is that it is a bit odd to handle endianness after/before
> calling regmap_read/write(). Can you try set
> .val_format_endian_default = REGMAP_ENDIAN_BIG, in ad4030_regmap_bus?
> If that doesn't help, what about doing the get/set_unaligned stuff within
> the bus read/write calls?
Unless these are all 16 bit registers (in which case push it into the
regmap side of things), then a bulk read is not implying the registers
read are one value. They could just be a load of registers next to each other.
As such the regmap core won't touch them and endian conversion here, at the
layer where we know they are related is the right thing to do.
It's not worth dual regmap stuff just because we have a few pairs of
registers.
>
> > +
> > + /* From datasheet: multiplied output = input × gain word/0x8000 */
> > + *val = gain / 0x8000;
> Use a define to give a name to the gain constant?
>
> > + *val2 = mul_u64_u32_div(gain % 0x8000, NANO, 0x8000);
> > +
> > + return IIO_VAL_INT_PLUS_NANO;
> > +}
> > +
> [...]
next prev parent reply other threads:[~2024-12-23 12:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 16:10 [PATCH v2 0/6] iio: adc: ad4030: new driver for AD4030 and similar ADCs Esteban Blanc
2024-12-19 16:10 ` [PATCH v2 1/6] dt-bindings: iio: adc: add ADI ad4030, ad4630 and ad4632 Esteban Blanc
2024-12-19 16:10 ` [PATCH v2 2/6] iio: adc: ad4030: add driver for ad4030-24 Esteban Blanc
2024-12-20 16:39 ` kernel test robot
2024-12-21 7:14 ` kernel test robot
2024-12-22 5:57 ` Marcelo Schmitt
2024-12-23 12:04 ` Jonathan Cameron [this message]
2025-01-10 14:39 ` Esteban Blanc
2025-01-16 9:56 ` Esteban Blanc
2024-12-23 12:15 ` Jonathan Cameron
2024-12-19 16:10 ` [PATCH v2 3/6] iio: adc: ad4030: add averaging support Esteban Blanc
2024-12-19 16:10 ` [PATCH v2 4/6] iio: adc: ad4030: add support for ad4630-24 and ad4630-16 Esteban Blanc
2024-12-19 16:10 ` [PATCH v2 5/6] iio: adc: ad4030: add support for ad4632-16 and ad4632-24 Esteban Blanc
2024-12-19 16:10 ` [PATCH v2 6/6] docs: iio: ad4030: add documentation Esteban Blanc
2024-12-23 12:23 ` 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=20241223120419.757eadfb@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=eblanc@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--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