From: Maxwell Doose <m32285159@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-iio@vger.kernel.org, "Jonathan Cameron" <jic23@kernel.org>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Tomasz Duszynski" <tomasz.duszynski@octakon.com>
Subject: Re: [PATCH v6] iio: chemical: scd30: Replace manual locking with RAII locking
Date: Mon, 1 Jun 2026 11:52:34 -0500 [thread overview]
Message-ID: <20260601115234.36867d97@linuxescape> (raw)
In-Reply-To: <e0a07428-9931-42d5-8b29-f92806ec39a9@web.de>
Hi Markus,
On Mon, 1 Jun 2026 17:38:44 +0200
Markus Elfring <Markus.Elfring@web.de> wrote:
> > scd30_core.c currently uses manual mutex_lock() and mutex_unlock()
> > calls. Replace them with the newer guard(mutex)() for cleaner RAII
> > patterns and to improve maintainability.
> …
> > In addition, small refactor to replace "?:" operator with regular
> > if/else returns.
>
> How does such an information fit to a known patch requirement?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.1-rc5#n81
>
Good point. However, I think that it's such a small change that nobody
is going to care that much. We'll see what Jonathan has to say, I
suppose.
>
> …
> > +++ b/drivers/iio/chemical/scd30_core.c
> > @@ -368,11 +368,13 @@ static ssize_t calibration_auto_enable_show(struct device *dev, struct device_at
> > int ret;
> > u16 val;
> >
> > - mutex_lock(&state->lock);
> > - ret = scd30_command_read(state, CMD_ASC, &val);
> > - mutex_unlock(&state->lock);
> > + guard(mutex)(&state->lock);
> >
> > - return ret ?: sysfs_emit(buf, "%d\n", val);
> …
>
> How do you think about to preserve lock scopes by using scoped_guard() calls?
>
Generally scoped_guard() (at least in my experience in iio) is frowned
upon because of the hidden for loop that can make normal things (e.g.,
break, continue) really weird, plus guard()() with {} is also (in my
experience) more popular over scoped_guard(). In the past helpers have
also been liked over both as well.
--
best regards,
max
next prev parent reply other threads:[~2026-06-01 16:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-31 23:38 [PATCH v6] iio: chemical: scd30: Replace manual locking with RAII locking Maxwell Doose
2026-06-01 13:35 ` Joshua Crofts
2026-06-01 15:38 ` Markus Elfring
2026-06-01 16:52 ` Maxwell Doose [this message]
2026-06-01 19:25 ` Joshua Crofts
2026-06-02 9:15 ` Andy Shevchenko
2026-06-03 13:54 ` 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=20260601115234.36867d97@linuxescape \
--to=m32285159@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=tomasz.duszynski@octakon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.