From: Jonathan Cameron <jic23@kernel.org>
To: Dmitry Rokosov <DDRokosov@sberdevices.ru>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"stano.jakubek@gmail.com" <stano.jakubek@gmail.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"lars@metafoo.de" <lars@metafoo.de>,
"stephan@gerhold.net" <stephan@gerhold.net>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
kernel <kernel@sberdevices.ru>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver
Date: Sun, 19 Jun 2022 13:31:42 +0100 [thread overview]
Message-ID: <20220619133142.0ca36d2e@jic23-huawei> (raw)
In-Reply-To: <20220616170218.dihjli46spimozeg@CAB-WSD-L081021.sigma.sbrf.ru>
On Thu, 16 Jun 2022 17:02:08 +0000
Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
> > > + err = -EINVAL;
> > > + mutex_lock(&msa311->lock);
> > > + for (odr = 0; odr < ARRAY_SIZE(msa311_odr_table); ++odr)
> > > + if (val == msa311_odr_table[odr].val &&
> > > + val2 == msa311_odr_table[odr].val2) {
> > > + err = msa311_set_odr(msa311, odr);
> >
> > > + if (err) {
> > > + dev_err(dev, "cannot update freq (%d)\n", err);
> > > + goto failed;
> > > + }
> >
> > Why is this inside the loop and more important under lock? Also you
> > may cover the initial error code by this message when moving it out of
> > the loop and lock.
> >
> > Ditto for other code snippets in other function(s) where applicable.
> >
>
> Yes, I can move dev_err() outside of loop. But all ODR search loop
> should be under lock fully, because other msa311 operations should not
> be executed when we search proper ODR place.
I don't see why? The search itself is for a match of the input to const data.
That can occur before taking the lock to do the actual write.
I don't see any additional race beyond the one that is always there of
a thread updating ODR whilst another is accessing the device. Which order
those events happen in is not controlled by the driver, but the output
will be consistent with one or other order of those two accesses.
Jonathan
next prev parent reply other threads:[~2022-06-19 12:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 10:42 [PATCH v3 0/3] iio: accel: add MSA311 accelerometer driver Dmitry Rokosov
2022-06-16 10:42 ` [PATCH v3 1/3] dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd Dmitry Rokosov
2022-06-16 10:42 ` [PATCH v3 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver Dmitry Rokosov
2022-06-16 12:18 ` Andy Shevchenko
2022-06-16 17:02 ` Dmitry Rokosov
2022-06-16 18:38 ` Andy Shevchenko
2022-06-17 14:22 ` Dmitry Rokosov
2022-06-17 16:54 ` Andy Shevchenko
2022-06-19 12:31 ` Jonathan Cameron [this message]
2022-07-01 13:06 ` Dmitry Rokosov
2022-06-19 12:27 ` Jonathan Cameron
2022-07-01 13:49 ` Dmitry Rokosov
2022-07-16 15:51 ` Jonathan Cameron
2022-07-18 10:01 ` Dmitry Rokosov
2022-06-16 10:42 ` [PATCH v3 3/3] dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver Dmitry Rokosov
2022-06-19 11:40 ` 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=20220619133142.0ca36d2e@jic23-huawei \
--to=jic23@kernel.org \
--cc=DDRokosov@sberdevices.ru \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=kernel@sberdevices.ru \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=stano.jakubek@gmail.com \
--cc=stephan@gerhold.net \
/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