From: Jonathan Cameron <jic23@kernel.org>
To: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
Cc: lucas.p.stankus@gmail.com, lars@metafoo.de,
Michael.Hennerich@analog.com, nuno.sa@analog.com,
andy@kernel.org, puranjay@kernel.org, dlechner@baylibre.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: accel: adxl372: convert to guard(mutex)
Date: Sat, 7 Mar 2026 17:11:44 +0000 [thread overview]
Message-ID: <20260307171144.46d42799@jic23-huawei> (raw)
In-Reply-To: <20260307114912.58062-3-rajveer.chaudhari.linux@gmail.com>
On Sat, 7 Mar 2026 17:19:12 +0530
Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> wrote:
> Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
> adxl372_write_threshold_value(). This ensures the mutex is released
> on all return paths and allows returning directly without a goto label.
>
> Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
Series applied. One small tweak mentioned below.
Applied to the testing branch of iio.git where the bots poke at it
briefly before I push it out as togreg which linux-next picks up.
Thanks,
Jonathan
> ---
> v4: Changelog moved below --- as requested by Jonathan Cameron.
> v3: Return directly from error path without goto.
> v2: Split into separate patch per driver.
> ---
> drivers/iio/accel/adxl372.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index 28a8793a53b6..4bf8656991ea 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -7,6 +7,7 @@
>
> #include <linux/bitfield.h>
> #include <linux/bitops.h>
> +#include <linux/cleanup.h>
> #include <linux/interrupt.h>
> #include <linux/irq.h>
> #include <linux/module.h>
> @@ -336,18 +337,14 @@ static ssize_t adxl372_write_threshold_value(struct iio_dev *indio_dev, unsigned
> struct adxl372_state *st = iio_priv(indio_dev);
> int ret;
>
> - mutex_lock(&st->threshold_m);
> + guard(mutex)(&st->threshold_m);
> +
> ret = regmap_write(st->regmap, addr, ADXL372_THRESH_VAL_H_SEL(threshold));
> if (ret < 0)
> - goto unlock;
> + return ret;
>
> - ret = regmap_update_bits(st->regmap, addr + 1, GENMASK(7, 5),
> + return regmap_update_bits(st->regmap, addr + 1, GENMASK(7, 5),
> ADXL372_THRESH_VAL_L_SEL(threshold) << 5);
I'd expect a minor indent update to be needed here. 1 more space.
> -
> -unlock:
> - mutex_unlock(&st->threshold_m);
> -
> - return ret;
> }
>
> static int adxl372_read_axis(struct adxl372_state *st, u8 addr)
prev parent reply other threads:[~2026-03-07 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 11:49 [PATCH v4 0/2] iio: accel: " Rajveer Chaudhari
2026-03-07 11:49 ` [PATCH v4 1/2] iio: accel: adxl313: " Rajveer Chaudhari
2026-03-07 11:49 ` [PATCH v4 2/2] iio: accel: adxl372: " Rajveer Chaudhari
2026-03-07 17:11 ` 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=20260307171144.46d42799@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.p.stankus@gmail.com \
--cc=nuno.sa@analog.com \
--cc=puranjay@kernel.org \
--cc=rajveer.chaudhari.linux@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®