From: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
To: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, waqar.hameed@axis.com, linusw@kernel.org,
sakari.ailus@linux.intel.com, harshit.m.mogalapalli@oracle.com,
antoniu.miclaus@analog.com, andrew.ijano@gmail.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
Subject: [PATCH 3/4] iio: accel: mma9551: convert to guard(mutex)
Date: Mon, 9 Mar 2026 19:53:51 +0530 [thread overview]
Message-ID: <20260309142352.57407-4-rajveer.chaudhari.linux@gmail.com> (raw)
In-Reply-To: <20260309142352.57407-1-rajveer.chaudhari.linux@gmail.com>
Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
mma9551_event_handler(). This ensures the mutex is
released on all return paths and allows returning directly
without a goto label.
Aligned headers in alphabatical order.
Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
drivers/iio/accel/mma9551.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 02195deada49..0936b148e424 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -4,17 +4,21 @@
* Copyright (c) 2014, Intel Corporation.
*/
+#include <linux/cleanup.h>
+#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
-#include <linux/delay.h>
+
#include <linux/gpio/consumer.h>
+
+#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
-#include <linux/iio/events.h>
-#include <linux/pm_runtime.h>
+
#include "mma9551_core.h"
#define MMA9551_GPIO_COUNT 4
@@ -337,7 +341,7 @@ static irqreturn_t mma9551_event_handler(int irq, void *private)
u16 reg;
u8 val;
- mutex_lock(&data->mutex);
+ guard(mutex)(&data->mutex);
for (i = 0; i < 3; i++)
if (irq == data->irqs[i]) {
@@ -349,7 +353,7 @@ static irqreturn_t mma9551_event_handler(int irq, void *private)
/* IRQ was triggered on 4th line, which we don't use. */
dev_warn(&data->client->dev,
"irq triggered on unused line %d\n", data->irqs[3]);
- goto out;
+ return IRQ_HANDLED;
}
switch (mma_axis) {
@@ -373,7 +377,7 @@ static irqreturn_t mma9551_event_handler(int irq, void *private)
if (ret < 0) {
dev_err(&data->client->dev,
"error %d reading tilt register in IRQ\n", ret);
- goto out;
+ return IRQ_HANDLED;
}
iio_push_event(indio_dev,
@@ -381,9 +385,6 @@ static irqreturn_t mma9551_event_handler(int irq, void *private)
IIO_EV_TYPE_ROC, IIO_EV_DIR_RISING),
iio_get_time_ns(indio_dev));
-out:
- mutex_unlock(&data->mutex);
-
return IRQ_HANDLED;
}
--
2.53.0
next prev parent reply other threads:[~2026-03-09 14:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 14:23 [PATCH 0/4] iio: accel: convert to guard(mutex) Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 1/4] iio: accel: bmc150: " Rajveer Chaudhari
2026-03-09 14:34 ` Rajveer Chaudhari
2026-03-09 14:35 ` Waqar Hameed
2026-03-09 16:26 ` Andy Shevchenko
2026-03-09 16:48 ` Waqar Hameed
2026-03-09 17:25 ` Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 2/4] iio: accel: mma8452: " Rajveer Chaudhari
2026-03-09 14:23 ` Rajveer Chaudhari [this message]
2026-03-09 14:23 ` [PATCH 4/4] iio: accel: sca3000: " Rajveer Chaudhari
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=20260309142352.57407-4-rajveer.chaudhari.linux@gmail.com \
--to=rajveer.chaudhari.linux@gmail.com \
--cc=andrew.ijano@gmail.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=dlechner@baylibre.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=jic23@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sakari.ailus@linux.intel.com \
--cc=waqar.hameed@axis.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