public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/8] iio: accel: convert to guard(mutex)
@ 2026-03-14 17:06 Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically Rajveer Chaudhari
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

This series converts manual mutex_lock/mutex_unlock pairs to
guard(mutex) in two ADXL accelerometer drivers. Each conversion
also simplifies error handling by removing goto labels and
returning directly on error paths.

v4 : Sort Headers alphabetically

Link to v3: https://lore.kernel.org/all/20260312081942.23858-1-
rajveer.chaudhari.linux@gmail.com/

Rajveer Chaudhari (8):
  iio: accel: bmc150: sort headers alphabetically
  iio: accel: bmc150: convert to guard(mutex)
  iio: accel: mma8452: sort headers alphabetically
  iio: accel: mma8452: convert to guard(mutex)
  iio: accel: mma9551: sort headers alphabetically
  iio: accel: mma9551: convert to guard(mutex)
  iio: accel: sca3000: sort headers alphabetically
  iio: accel: sca3000: convert to guard(mutex)

 drivers/iio/accel/bmc150-accel-core.c |  38 +++----
 drivers/iio/accel/mma8452.c           |  38 +++----
 drivers/iio/accel/mma9551.c           |  19 ++--
 drivers/iio/accel/sca3000.c           | 157 ++++++++++++--------------
 4 files changed, 115 insertions(+), 137 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 19:41   ` David Lechner
  2026-03-14 17:06 ` [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex) Rajveer Chaudhari
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
v4 : Patch added in v4
---
 drivers/iio/accel/bmc150-accel-core.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 42ccf0316ce5..4eb4293a741d 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -4,23 +4,26 @@
  * Copyright (c) 2014, Intel Corporation.
  */
 
-#include <linux/module.h>
+#include <linux/acpi.h>
+#include <linux/cleanup.h>
+#include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/acpi.h>
+#include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include <linux/regmap.h>
+
 #include <linux/regulator/consumer.h>
 
 #include "bmc150-accel.h"
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex)
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-15 23:15   ` Linus Walleij
  2026-03-14 17:06 ` [PATCH v4 3/8] iio: accel: mma8452: sort headers alphabetically Rajveer Chaudhari
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Replace manual mutex_lock/mutex_unlock pair with guard(mutex)
in bmc150_accel_buffer_predisable() and
bmc150_accel_buffer_postenable(). 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>
---
v4: No changes

v3: stop initialising ret=0 at start, making clear about good path.
moved return ret up into the if (ret) {} block in
bmc150_accel_buffer_postenable().

v2: Cleaned mutex_unlock and goto in
bmc150_accel_buffer_postenable(),
Dropped Header alignment change.
---
 drivers/iio/accel/bmc150-accel-core.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 4eb4293a741d..d3214be54819 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -1483,20 +1483,20 @@ static int bmc150_accel_buffer_preenable(struct iio_dev *indio_dev)
 static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev)
 {
 	struct bmc150_accel_data *data = iio_priv(indio_dev);
-	int ret = 0;
+	int ret;
 
 	if (iio_device_get_current_mode(indio_dev) == INDIO_BUFFER_TRIGGERED)
 		return 0;
 
-	mutex_lock(&data->mutex);
+	guard(mutex)(&data->mutex);
 
 	if (!data->watermark)
-		goto out;
+		return 0;
 
 	ret = bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK,
 					 true);
 	if (ret)
-		goto out;
+		return ret;
 
 	data->fifo_mode = BMC150_ACCEL_FIFO_MODE_FIFO;
 
@@ -1505,12 +1505,10 @@ static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev)
 		data->fifo_mode = 0;
 		bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK,
 					   false);
+		return ret;
 	}
 
-out:
-	mutex_unlock(&data->mutex);
-
-	return ret;
+	return 0;
 }
 
 static int bmc150_accel_buffer_predisable(struct iio_dev *indio_dev)
@@ -1520,19 +1518,16 @@ static int bmc150_accel_buffer_predisable(struct iio_dev *indio_dev)
 	if (iio_device_get_current_mode(indio_dev) == INDIO_BUFFER_TRIGGERED)
 		return 0;
 
-	mutex_lock(&data->mutex);
+	guard(mutex)(&data->mutex);
 
 	if (!data->fifo_mode)
-		goto out;
+		return 0;
 
 	bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK, false);
 	__bmc150_accel_fifo_flush(indio_dev, BMC150_ACCEL_FIFO_LENGTH, false);
 	data->fifo_mode = 0;
 	bmc150_accel_fifo_set_mode(data);
 
-out:
-	mutex_unlock(&data->mutex);
-
 	return 0;
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 3/8] iio: accel: mma8452: sort headers alphabetically
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 4/8] iio: accel: mma8452: convert to guard(mutex) Rajveer Chaudhari
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
v4 : Patch added in v4
---
 drivers/iio/accel/mma8452.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 15172ba2972c..79ee4dff0ff6 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -17,22 +17,24 @@
  *
  * TODO: orientation events
  */
-
-#include <linux/module.h>
+#include <linux/cleanup.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
 #include <linux/property.h>
-#include <linux/i2c.h>
+#include <linux/types.h>
+
+#include <linux/iio/buffer.h>
+#include <linux/iio/events.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include <linux/iio/events.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
+
 #include <linux/regulator/consumer.h>
-#include <linux/types.h>
 
 #define MMA8452_STATUS				0x00
 #define  MMA8452_STATUS_DRDY			(BIT(2) | BIT(1) | BIT(0))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 4/8] iio: accel: mma8452: convert to guard(mutex)
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (2 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 3/8] iio: accel: mma8452: sort headers alphabetically Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 5/8] iio: accel: mma9551: sort headers alphabetically Rajveer Chaudhari
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
mma8452_change_config(). 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>
---
v4: No changes

v3 : No changes

v2 : Dropped Header alignment change
---
 drivers/iio/accel/mma8452.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 79ee4dff0ff6..16d9124b844c 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -599,36 +599,30 @@ static int mma8452_change_config(struct mma8452_data *data, u8 reg, u8 val)
 	int ret;
 	int is_active;
 
-	mutex_lock(&data->lock);
+	guard(mutex)(&data->lock);
 
 	is_active = mma8452_is_active(data);
-	if (is_active < 0) {
-		ret = is_active;
-		goto fail;
-	}
+	if (is_active < 0)
+		return is_active;
 
 	/* config can only be changed when in standby */
 	if (is_active > 0) {
 		ret = mma8452_standby(data);
 		if (ret < 0)
-			goto fail;
+			return ret;
 	}
 
 	ret = i2c_smbus_write_byte_data(data->client, reg, val);
 	if (ret < 0)
-		goto fail;
+		return ret;
 
 	if (is_active > 0) {
 		ret = mma8452_active(data);
 		if (ret < 0)
-			goto fail;
+			return ret;
 	}
 
-	ret = 0;
-fail:
-	mutex_unlock(&data->lock);
-
-	return ret;
+	return 0;
 }
 
 static int mma8452_set_power_mode(struct mma8452_data *data, u8 mode)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 5/8] iio: accel: mma9551: sort headers alphabetically
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (3 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 4/8] iio: accel: mma8452: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 6/8] iio: accel: mma9551: convert to guard(mutex) Rajveer Chaudhari
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
v4: Patch added in v4
---
 drivers/iio/accel/mma9551.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 02195deada49..31e5c3699c19 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
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 6/8] iio: accel: mma9551: convert to guard(mutex)
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (4 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 5/8] iio: accel: mma9551: sort headers alphabetically Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 7/8] iio: accel: sca3000: sort headers alphabetically Rajveer Chaudhari
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

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.

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
v4: No Changes

v3: No Changes

v2: Dropped Header alignment change
---
 drivers/iio/accel/mma9551.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 31e5c3699c19..0936b148e424 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -341,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]) {
@@ -353,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) {
@@ -377,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,
@@ -385,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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 7/8] iio: accel: sca3000: sort headers alphabetically
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (5 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 6/8] iio: accel: mma9551: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 17:06 ` [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex) Rajveer Chaudhari
  2026-03-15 19:05 ` [PATCH v4 0/8] iio: accel: " Jonathan Cameron
  8 siblings, 0 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
v4: Patch added in v4
---
 drivers/iio/accel/sca3000.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 4a827be439a2..d61ad12aef78 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -7,20 +7,23 @@
  * See industrialio/accels/sca3000.h for comments.
  */
 
-#include <linux/interrupt.h>
-#include <linux/fs.h>
+#include <linux/cleanup.h>
 #include <linux/device.h>
-#include <linux/slab.h>
+#include <linux/fs.h>
+#include <linux/interrupt.h>
 #include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/sysfs.h>
 #include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
 #include <linux/uaccess.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/events.h>
+
 #include <linux/iio/buffer.h>
+#include <linux/iio/events.h>
+#include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
+#include <linux/iio/sysfs.h>
+
+#include <linux/spi/spi.h>
 
 #define SCA3000_WRITE_REG(a) (((a) << 2) | 0x02)
 #define SCA3000_READ_REG(a) ((a) << 2)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex)
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (6 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 7/8] iio: accel: sca3000: sort headers alphabetically Rajveer Chaudhari
@ 2026-03-14 17:06 ` Rajveer Chaudhari
  2026-03-14 19:45   ` David Lechner
  2026-03-15 19:13   ` Jonathan Cameron
  2026-03-15 19:05 ` [PATCH v4 0/8] iio: accel: " Jonathan Cameron
  8 siblings, 2 replies; 14+ messages in thread
From: Rajveer Chaudhari @ 2026-03-14 17:06 UTC (permalink / raw)
  To: jic23, dlechner, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel, Rajveer Chaudhari

Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
sca3000_print_rev(), sca3000_ring_int_process(),
sca3000_read_event_config(), __sca3000_hw_ring_state_set(),
sca3000_hw_ring_preenable(), sca3000_hw_ring_postdisable(),
sca3000_clean_setup(), sca3000_stop_all_interrupts().
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>
---
v4: No changes

v3: Fixed return statements to make it clear about good/error path.
Removed Not necessary return statement in sca3000_read_event_config().
Dropped else statement to reduce indent of the code in
sca3000_read_event_config.
Fixed indentation.

v2: Dropped Header alignment change
---
 drivers/iio/accel/sca3000.c | 138 +++++++++++++++---------------------
 1 file changed, 59 insertions(+), 79 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index d61ad12aef78..9703946f133d 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -427,18 +427,18 @@ static int sca3000_print_rev(struct iio_dev *indio_dev)
 	int ret;
 	struct sca3000_state *st = iio_priv(indio_dev);
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
+
 	ret = sca3000_read_data_short(st, SCA3000_REG_REVID_ADDR, 1);
 	if (ret < 0)
-		goto error_ret;
+		return ret;
+
 	dev_info(&indio_dev->dev,
 		 "sca3000 revision major=%lu, minor=%lu\n",
 		 st->rx[0] & SCA3000_REG_REVID_MAJOR_MASK,
 		 st->rx[0] & SCA3000_REG_REVID_MINOR_MASK);
-error_ret:
-	mutex_unlock(&st->lock);
 
-	return ret;
+	return 0;
 }
 
 static ssize_t
@@ -999,13 +999,14 @@ static void sca3000_ring_int_process(u8 val, struct iio_dev *indio_dev)
 	struct sca3000_state *st = iio_priv(indio_dev);
 	int ret, i, num_available;
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
 
 	if (val & SCA3000_REG_INT_STATUS_HALF) {
 		ret = sca3000_read_data_short(st, SCA3000_REG_BUF_COUNT_ADDR,
 					      1);
 		if (ret)
-			goto error_ret;
+			return;
+
 		num_available = st->rx[0];
 		/*
 		 * num_available is the total number of samples available
@@ -1014,7 +1015,8 @@ static void sca3000_ring_int_process(u8 val, struct iio_dev *indio_dev)
 		ret = sca3000_read_data(st, SCA3000_REG_RING_OUT_ADDR, st->rx,
 					num_available * 2);
 		if (ret)
-			goto error_ret;
+			return;
+
 		for (i = 0; i < num_available / 3; i++) {
 			/*
 			 * Dirty hack to cover for 11 bit in fifo, 13 bit
@@ -1026,8 +1028,6 @@ static void sca3000_ring_int_process(u8 val, struct iio_dev *indio_dev)
 			iio_push_to_buffers(indio_dev, st->rx + i * 3 * 2);
 		}
 	}
-error_ret:
-	mutex_unlock(&st->lock);
 }
 
 /**
@@ -1113,16 +1113,15 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
 	struct sca3000_state *st = iio_priv(indio_dev);
 	int ret;
 	/* read current value of mode register */
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
 
 	ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
 	if (ret)
-		goto error_ret;
+		return ret;
 
 	switch (chan->channel2) {
 	case IIO_MOD_X_AND_Y_AND_Z:
-		ret = !!(st->rx[0] & SCA3000_REG_MODE_FREE_FALL_DETECT);
-		break;
+		return !!(st->rx[0] & SCA3000_REG_MODE_FREE_FALL_DETECT);
 	case IIO_MOD_X:
 	case IIO_MOD_Y:
 	case IIO_MOD_Z:
@@ -1132,24 +1131,18 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
 		 */
 		if ((st->rx[0] & SCA3000_REG_MODE_MODE_MASK)
 		    != SCA3000_REG_MODE_MEAS_MODE_MOT_DET) {
-			ret = 0;
-		} else {
-			ret = sca3000_read_ctrl_reg(st,
-						SCA3000_REG_CTRL_SEL_MD_CTRL);
-			if (ret < 0)
-				goto error_ret;
-			/* only supporting logical or's for now */
-			ret = !!(ret & sca3000_addresses[chan->address][2]);
+			return 0;
 		}
-		break;
+
+		ret = sca3000_read_ctrl_reg(st,
+					SCA3000_REG_CTRL_SEL_MD_CTRL);
+		if (ret < 0)
+			return ret;
+		/* only supporting logical or's for now */
+		return !!(ret & sca3000_addresses[chan->address][2]);
 	default:
-		ret = -EINVAL;
+		return -EINVAL;
 	}
-
-error_ret:
-	mutex_unlock(&st->lock);
-
-	return ret;
 }
 
 static int sca3000_freefall_set_state(struct iio_dev *indio_dev, bool state)
@@ -1280,23 +1273,21 @@ int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
 	struct sca3000_state *st = iio_priv(indio_dev);
 	int ret;
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
+
 	ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
 	if (ret)
-		goto error_ret;
+		return ret;
+
 	if (state) {
 		dev_info(&indio_dev->dev, "supposedly enabling ring buffer\n");
-		ret = sca3000_write_reg(st,
+		return sca3000_write_reg(st,
 			SCA3000_REG_MODE_ADDR,
 			(st->rx[0] | SCA3000_REG_MODE_RING_BUF_ENABLE));
 	} else
-		ret = sca3000_write_reg(st,
+		return sca3000_write_reg(st,
 			SCA3000_REG_MODE_ADDR,
 			(st->rx[0] & ~SCA3000_REG_MODE_RING_BUF_ENABLE));
-error_ret:
-	mutex_unlock(&st->lock);
-
-	return ret;
 }
 
 /**
@@ -1313,26 +1304,20 @@ static int sca3000_hw_ring_preenable(struct iio_dev *indio_dev)
 	int ret;
 	struct sca3000_state *st = iio_priv(indio_dev);
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
 
 	/* Enable the 50% full interrupt */
 	ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
 	if (ret)
-		goto error_unlock;
+		return ret;
+
 	ret = sca3000_write_reg(st,
 				SCA3000_REG_INT_MASK_ADDR,
 				st->rx[0] | SCA3000_REG_INT_MASK_RING_HALF);
 	if (ret)
-		goto error_unlock;
-
-	mutex_unlock(&st->lock);
+		return ret;
 
 	return __sca3000_hw_ring_state_set(indio_dev, 1);
-
-error_unlock:
-	mutex_unlock(&st->lock);
-
-	return ret;
 }
 
 static int sca3000_hw_ring_postdisable(struct iio_dev *indio_dev)
@@ -1345,17 +1330,15 @@ static int sca3000_hw_ring_postdisable(struct iio_dev *indio_dev)
 		return ret;
 
 	/* Disable the 50% full interrupt */
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
 
 	ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
 	if (ret)
-		goto unlock;
-	ret = sca3000_write_reg(st,
-				SCA3000_REG_INT_MASK_ADDR,
-				st->rx[0] & ~SCA3000_REG_INT_MASK_RING_HALF);
-unlock:
-	mutex_unlock(&st->lock);
-	return ret;
+		return ret;
+
+	return sca3000_write_reg(st,
+				 SCA3000_REG_INT_MASK_ADDR,
+				 st->rx[0] & ~SCA3000_REG_INT_MASK_RING_HALF);
 }
 
 static const struct iio_buffer_setup_ops sca3000_ring_setup_ops = {
@@ -1375,25 +1358,26 @@ static int sca3000_clean_setup(struct sca3000_state *st)
 {
 	int ret;
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
+
 	/* Ensure all interrupts have been acknowledged */
 	ret = sca3000_read_data_short(st, SCA3000_REG_INT_STATUS_ADDR, 1);
 	if (ret)
-		goto error_ret;
+		return ret;
 
 	/* Turn off all motion detection channels */
 	ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
 	if (ret < 0)
-		goto error_ret;
+		return ret;
 	ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL,
 				     ret & SCA3000_MD_CTRL_PROT_MASK);
 	if (ret)
-		goto error_ret;
+		return ret;
 
 	/* Disable ring buffer */
 	ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
 	if (ret < 0)
-		goto error_ret;
+		return ret;
 	ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL,
 				     (ret & SCA3000_REG_OUT_CTRL_PROT_MASK)
 				     | SCA3000_REG_OUT_CTRL_BUF_X_EN
@@ -1401,17 +1385,17 @@ static int sca3000_clean_setup(struct sca3000_state *st)
 				     | SCA3000_REG_OUT_CTRL_BUF_Z_EN
 				     | SCA3000_REG_OUT_CTRL_BUF_DIV_4);
 	if (ret)
-		goto error_ret;
+		return ret;
 	/* Enable interrupts, relevant to mode and set up as active low */
 	ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
 	if (ret)
-		goto error_ret;
+		return ret;
 	ret = sca3000_write_reg(st,
 				SCA3000_REG_INT_MASK_ADDR,
 				(ret & SCA3000_REG_INT_MASK_PROT_MASK)
 				| SCA3000_REG_INT_MASK_ACTIVE_LOW);
 	if (ret)
-		goto error_ret;
+		return ret;
 	/*
 	 * Select normal measurement mode, free fall off, ring off
 	 * Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
@@ -1419,13 +1403,10 @@ static int sca3000_clean_setup(struct sca3000_state *st)
 	 */
 	ret = sca3000_read_data_short(st, SCA3000_REG_MODE_ADDR, 1);
 	if (ret)
-		goto error_ret;
-	ret = sca3000_write_reg(st, SCA3000_REG_MODE_ADDR,
-				(st->rx[0] & SCA3000_MODE_PROT_MASK));
+		return ret;
 
-error_ret:
-	mutex_unlock(&st->lock);
-	return ret;
+	return sca3000_write_reg(st, SCA3000_REG_MODE_ADDR,
+				(st->rx[0] & SCA3000_MODE_PROT_MASK));
 }
 
 static const struct iio_info sca3000_info = {
@@ -1507,18 +1488,17 @@ static int sca3000_stop_all_interrupts(struct sca3000_state *st)
 {
 	int ret;
 
-	mutex_lock(&st->lock);
+	guard(mutex)(&st->lock);
+
 	ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
 	if (ret)
-		goto error_ret;
-	ret = sca3000_write_reg(st, SCA3000_REG_INT_MASK_ADDR,
-				(st->rx[0] &
-				 ~(SCA3000_REG_INT_MASK_RING_THREE_QUARTER |
-				   SCA3000_REG_INT_MASK_RING_HALF |
-				   SCA3000_REG_INT_MASK_ALL_INTS)));
-error_ret:
-	mutex_unlock(&st->lock);
-	return ret;
+		return ret;
+
+	return sca3000_write_reg(st, SCA3000_REG_INT_MASK_ADDR,
+				 (st->rx[0] &
+				  ~(SCA3000_REG_INT_MASK_RING_THREE_QUARTER |
+				    SCA3000_REG_INT_MASK_RING_HALF |
+				    SCA3000_REG_INT_MASK_ALL_INTS)));
 }
 
 static void sca3000_remove(struct spi_device *spi)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically
  2026-03-14 17:06 ` [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically Rajveer Chaudhari
@ 2026-03-14 19:41   ` David Lechner
  0 siblings, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-03-14 19:41 UTC (permalink / raw)
  To: Rajveer Chaudhari, jic23, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel

On 3/14/26 12:06 PM, Rajveer Chaudhari wrote:
> Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
> ---
> v4 : Patch added in v4
> ---
>  drivers/iio/accel/bmc150-accel-core.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
> index 42ccf0316ce5..4eb4293a741d 100644
> --- a/drivers/iio/accel/bmc150-accel-core.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -4,23 +4,26 @@
>   * Copyright (c) 2014, Intel Corporation.
>   */
>  
> -#include <linux/module.h>
> +#include <linux/acpi.h>
> +#include <linux/cleanup.h>

Should not add cleanup.h until the next patch.

> +#include <linux/delay.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> -#include <linux/delay.h>
> -#include <linux/slab.h>
> -#include <linux/acpi.h>
> +#include <linux/module.h>
>  #include <linux/pm.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/property.h>
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
> +
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/events.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
>  #include <linux/iio/trigger.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
> -#include <linux/regmap.h>
> +
>  #include <linux/regulator/consumer.h>
>  
>  #include "bmc150-accel.h"


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex)
  2026-03-14 17:06 ` [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-14 19:45   ` David Lechner
  2026-03-15 19:13   ` Jonathan Cameron
  1 sibling, 0 replies; 14+ messages in thread
From: David Lechner @ 2026-03-14 19:45 UTC (permalink / raw)
  To: Rajveer Chaudhari, jic23, nuno.sa, andy, waqar.hameed, linusw,
	sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
	andrew.ijano
  Cc: linux-iio, linux-kernel

On 3/14/26 12:06 PM, Rajveer Chaudhari wrote:
> Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
> sca3000_print_rev(), sca3000_ring_int_process(),
> sca3000_read_event_config(), __sca3000_hw_ring_state_set(),
> sca3000_hw_ring_preenable(), sca3000_hw_ring_postdisable(),
> sca3000_clean_setup(), sca3000_stop_all_interrupts().
> 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>
> ---

...

> @@ -1132,24 +1131,18 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
>  		 */
>  		if ((st->rx[0] & SCA3000_REG_MODE_MODE_MASK)
>  		    != SCA3000_REG_MODE_MEAS_MODE_MOT_DET) {

can drop this { now.

> -			ret = 0;
> -		} else {
> -			ret = sca3000_read_ctrl_reg(st,
> -						SCA3000_REG_CTRL_SEL_MD_CTRL);
> -			if (ret < 0)
> -				goto error_ret;
> -			/* only supporting logical or's for now */
> -			ret = !!(ret & sca3000_addresses[chan->address][2]);
> +			return 0;
>  		}
> -		break;
> +
> +		ret = sca3000_read_ctrl_reg(st,
> +					SCA3000_REG_CTRL_SEL_MD_CTRL);
> +		if (ret < 0)
> +			return ret;
> +		/* only supporting logical or's for now */
> +		return !!(ret & sca3000_addresses[chan->address][2]);
>  	default:
> -		ret = -EINVAL;
> +		return -EINVAL;
>  	}
> -
> -error_ret:
> -	mutex_unlock(&st->lock);
> -
> -	return ret;
>  }
>  

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 0/8] iio: accel: convert to guard(mutex)
  2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
                   ` (7 preceding siblings ...)
  2026-03-14 17:06 ` [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-15 19:05 ` Jonathan Cameron
  8 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2026-03-15 19:05 UTC (permalink / raw)
  To: Rajveer Chaudhari
  Cc: dlechner, nuno.sa, andy, waqar.hameed, linusw, sakari.ailus,
	harshit.m.mogalapalli, antoniu.miclaus, andrew.ijano, linux-iio,
	linux-kernel

On Sat, 14 Mar 2026 22:36:01 +0530
Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> wrote:

> This series converts manual mutex_lock/mutex_unlock pairs to
> guard(mutex) in two ADXL accelerometer drivers. Each conversion

No it doesn't...

> also simplifies error handling by removing goto labels and
> returning directly on error paths.
> 
> v4 : Sort Headers alphabetically
> 
> Link to v3: https://lore.kernel.org/all/20260312081942.23858-1-
> rajveer.chaudhari.linux@gmail.com/

As per the thread on doing this stuff as a GSOC project, 
please don't do too many of these.  I don't mind people doing
one or two as a 'getting started' project but they do take non
trivial review and don't necessarily give sufficient benefit.

So on that note, maybe move on to other topics after this set!
I am in favour of these as part of more significant driver
improvement series though!

> 
> Rajveer Chaudhari (8):
>   iio: accel: bmc150: sort headers alphabetically
>   iio: accel: bmc150: convert to guard(mutex)
>   iio: accel: mma8452: sort headers alphabetically
>   iio: accel: mma8452: convert to guard(mutex)
>   iio: accel: mma9551: sort headers alphabetically
>   iio: accel: mma9551: convert to guard(mutex)
>   iio: accel: sca3000: sort headers alphabetically
>   iio: accel: sca3000: convert to guard(mutex)
> 
>  drivers/iio/accel/bmc150-accel-core.c |  38 +++----
>  drivers/iio/accel/mma8452.c           |  38 +++----
>  drivers/iio/accel/mma9551.c           |  19 ++--
>  drivers/iio/accel/sca3000.c           | 157 ++++++++++++--------------
>  4 files changed, 115 insertions(+), 137 deletions(-)
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex)
  2026-03-14 17:06 ` [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex) Rajveer Chaudhari
  2026-03-14 19:45   ` David Lechner
@ 2026-03-15 19:13   ` Jonathan Cameron
  1 sibling, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2026-03-15 19:13 UTC (permalink / raw)
  To: Rajveer Chaudhari
  Cc: dlechner, nuno.sa, andy, waqar.hameed, linusw, sakari.ailus,
	harshit.m.mogalapalli, antoniu.miclaus, andrew.ijano, linux-iio,
	linux-kernel

On Sat, 14 Mar 2026 22:36:09 +0530
Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> wrote:

> Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
> sca3000_print_rev(), sca3000_ring_int_process(),
> sca3000_read_event_config(), __sca3000_hw_ring_state_set(),
> sca3000_hw_ring_preenable(), sca3000_hw_ring_postdisable(),
> sca3000_clean_setup(), sca3000_stop_all_interrupts().
> 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>
Hi Rajveer,

The discussion about time to review these is particularly relevant here.
Unless I'm missing something you introduce a deadlock and more radical
surgery is needed to avoid that.

Jonathan

>  
>  /**
> @@ -1313,26 +1304,20 @@ static int sca3000_hw_ring_preenable(struct iio_dev *indio_dev)
>  	int ret;
>  	struct sca3000_state *st = iio_priv(indio_dev);
>  
> -	mutex_lock(&st->lock);
> +	guard(mutex)(&st->lock);
>  
>  	/* Enable the 50% full interrupt */
>  	ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
>  	if (ret)
> -		goto error_unlock;
> +		return ret;
> +
>  	ret = sca3000_write_reg(st,
>  				SCA3000_REG_INT_MASK_ADDR,
>  				st->rx[0] | SCA3000_REG_INT_MASK_RING_HALF);
>  	if (ret)
> -		goto error_unlock;
> -
> -	mutex_unlock(&st->lock);
> +		return ret;
This smells interesting... The scope has expanded.

Deadlock I believe as the guard() hasn't released here before
the one in __sca3000_hw_ring_state_set) tries to grab the same
lock.

The obvious fix would be a precursor patch to update the locking
so that doesn't happen.  There is always a dance where the lock
is released before making that call (or taken after it) so just
make it __must_hold() for the lock and don't take it again internally.


>  
>  	return __sca3000_hw_ring_state_set(indio_dev, 1);
> -
> -error_unlock:
> -	mutex_unlock(&st->lock);
> -
> -	return ret;
>  }



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex)
  2026-03-14 17:06 ` [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-15 23:15   ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2026-03-15 23:15 UTC (permalink / raw)
  To: Rajveer Chaudhari
  Cc: jic23, dlechner, nuno.sa, andy, waqar.hameed, sakari.ailus,
	harshit.m.mogalapalli, antoniu.miclaus, andrew.ijano, linux-iio,
	linux-kernel

On Sat, Mar 14, 2026 at 6:07 PM Rajveer Chaudhari
<rajveer.chaudhari.linux@gmail.com> wrote:

> Replace manual mutex_lock/mutex_unlock pair with guard(mutex)
> in bmc150_accel_buffer_predisable() and
> bmc150_accel_buffer_postenable(). 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>

This one is rather trivial and easy to review:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-03-15 23:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14 17:06 [PATCH v4 0/8] iio: accel: convert to guard(mutex) Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 1/8] iio: accel: bmc150: sort headers alphabetically Rajveer Chaudhari
2026-03-14 19:41   ` David Lechner
2026-03-14 17:06 ` [PATCH v4 2/8] iio: accel: bmc150: convert to guard(mutex) Rajveer Chaudhari
2026-03-15 23:15   ` Linus Walleij
2026-03-14 17:06 ` [PATCH v4 3/8] iio: accel: mma8452: sort headers alphabetically Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 4/8] iio: accel: mma8452: convert to guard(mutex) Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 5/8] iio: accel: mma9551: sort headers alphabetically Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 6/8] iio: accel: mma9551: convert to guard(mutex) Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 7/8] iio: accel: sca3000: sort headers alphabetically Rajveer Chaudhari
2026-03-14 17:06 ` [PATCH v4 8/8] iio: accel: sca3000: convert to guard(mutex) Rajveer Chaudhari
2026-03-14 19:45   ` David Lechner
2026-03-15 19:13   ` Jonathan Cameron
2026-03-15 19:05 ` [PATCH v4 0/8] iio: accel: " Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox