From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Gabriel Rondon <grondon@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Stepan Ionichev" <sozdayvek@gmail.com>,
"Maxwell Doose" <m32285159@gmail.com>,
"Yash Suthar" <yashsuthar983@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/3] iio: accel: bmc150: use guard(mutex) for mutex handling
Date: Mon, 17 Aug 2026 18:39:18 +0300 [thread overview]
Message-ID: <aoMrJvd4oSj0HgN4@ashevche-desk.local> (raw)
In-Reply-To: <20260816234231.14168-4-grondon@gmail.com>
On Mon, Aug 17, 2026 at 12:42:31AM +0100, Gabriel Rondon wrote:
> Replace manual mutex_lock()/mutex_unlock() pairs with guard(mutex) and
> scoped_guard() from cleanup.h in the functions where the critical
> section covers the whole function body or a single statement. This
> simplifies the error paths by removing the explicit unlock calls
> before returning.
>
> bmc150_accel_trigger_handler() only holds the lock around a single
> register read, so scoped_guard() is used there to keep the lock scope
> unchanged.
>
> Call sites that take and drop the mutex several times per function
> (read_raw, write_raw) or unlock through a goto label
> (buffer_postenable/predisable) are left untouched and can be converted
> separately.
...
> static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
> struct bmc150_accel_data *data = iio_priv(indio_dev);
> int ret;
>
> - mutex_lock(&data->mutex);
> - ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_REG_XOUT_L,
> - data->scan.channels, AXIS_MAX * 2);
> - mutex_unlock(&data->mutex);
> + scoped_guard(mutex, &data->mutex)
> + ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_REG_XOUT_L,
> + data->scan.channels, AXIS_MAX * 2);
> if (ret < 0)
> goto err_read;
Not directly related to this change, but even in the original code what is
protected here by the mutex? data->scan.channels?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-08-17 15:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 23:42 [PATCH v4 0/3] iio: accel: bmc150: fix event-enable race, then use guard(mutex) Gabriel Rondon
2026-08-16 23:42 ` [PATCH v4 1/3] iio: accel: bmc150: sort header inclusions alphabetically Gabriel Rondon
2026-08-17 15:35 ` Andy Shevchenko
2026-08-16 23:42 ` [PATCH v4 2/3] iio: accel: bmc150: take the lock before checking ev_enable_state Gabriel Rondon
2026-08-16 23:42 ` [PATCH v4 3/3] iio: accel: bmc150: use guard(mutex) for mutex handling Gabriel Rondon
2026-08-17 15:39 ` Andy Shevchenko [this message]
2026-08-18 15:41 ` Gabriel Rondon
2026-08-18 15:47 ` Andy Shevchenko
2026-08-22 22:11 ` Jonathan Cameron
2026-08-22 22:14 ` [PATCH v4 0/3] iio: accel: bmc150: fix event-enable race, then use guard(mutex) 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=aoMrJvd4oSj0HgN4@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=grondon@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m32285159@gmail.com \
--cc=nuno.sa@analog.com \
--cc=sozdayvek@gmail.com \
--cc=yashsuthar983@gmail.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
all inboxes | Powered by JetHome®