From: Jonathan Cameron <jic23@kernel.org>
To: Naresh Solanki <naresh.solanki@9elements.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>, Lee Jones <lee@kernel.org>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: max597x: Add support for max597x
Date: Sat, 25 Mar 2023 19:26:12 +0000 [thread overview]
Message-ID: <20230325192612.6181b07e@jic23-huawei> (raw)
In-Reply-To: <34756312-8a25-5a10-4ea5-59aeeb9e199b@9elements.com>
On Thu, 23 Mar 2023 17:31:18 +0530
Naresh Solanki <naresh.solanki@9elements.com> wrote:
> Hi,
>
> On 22-03-2023 09:28 pm, Lars-Peter Clausen wrote:
> > Hi,
> >
> > This looks really good. A few minor comments inline.
> >
> > On 3/22/23 05:43, Naresh Solanki wrote:
> >> [...]
> >> +static int max597x_iio_read_raw(struct iio_dev *iio_dev,
> >> + struct iio_chan_spec const *chan,
> >> + int *val, int *val2, long info)
> >> +{
> >> + int ret;
> >> + struct max597x_iio *data = iio_priv(iio_dev);
> >> + unsigned int reg_l, reg_h;
> >> +
> >> + switch (info) {
> >> + case IIO_CHAN_INFO_RAW:
> >> + ret = regmap_read(data->regmap, chan->address, ®_l);
> >> + if (ret < 0)
> >> + return ret;
> >> + ret = regmap_read(data->regmap, chan->address - 1, ®_h);
> >> + if (ret < 0)
> >> + return ret;
> > Is there any chance of a race condition of getting inconsistent data
> > when splitting this over two reads? I.e. registers being updated with
> > new values in between the two reads.
> yes, reg_l holds lower 2 bits. due to latency in reads, value may differ.
Normally there is a way to avoid the tearing via a bulk read of some type.
Is that not possible here? If not, there are various tricks such as
repeated reads until stable that can be used.
Looks like the device has a block read format that might work.
prev parent reply other threads:[~2023-03-25 19:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 12:43 [PATCH 1/2] iio: max597x: Add support for max597x Naresh Solanki
2023-03-22 15:43 ` kernel test robot
2023-03-22 15:58 ` Lars-Peter Clausen
2023-03-23 12:01 ` Naresh Solanki
2023-03-23 13:07 ` Lars-Peter Clausen
2023-03-23 13:47 ` Naresh Solanki
2023-03-25 19:26 ` Jonathan Cameron [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=20230325192612.6181b07e@jic23-huawei \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naresh.solanki@9elements.com \
--cc=patrick.rudolph@9elements.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