* [PATCH 0/4] iio: accel: convert to guard(mutex)
@ 2026-03-09 14:23 Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 1/4] iio: accel: bmc150: " Rajveer Chaudhari
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:23 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.
Also aligned headers alphabetically.
Rajveer Chaudhari (4):
iio: accel: bmc150: convert to guard(mutex)
iio: accel: mma8452: convert to guard(mutex)
iio: accel: mma9551: convert to guard(mutex)
iio: accel: sca3000: convert to guard(mutex)
drivers/iio/accel/bmc150-accel-core.c | 26 +++---
drivers/iio/accel/mma8452.c | 35 ++++----
drivers/iio/accel/mma9551.c | 19 +++--
drivers/iio/accel/sca3000.c | 115 ++++++++++++--------------
4 files changed, 91 insertions(+), 104 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
2026-03-09 14:23 [PATCH 0/4] iio: accel: convert to guard(mutex) Rajveer Chaudhari
@ 2026-03-09 14:23 ` Rajveer Chaudhari
2026-03-09 14:34 ` Rajveer Chaudhari
2026-03-09 14:35 ` Waqar Hameed
2026-03-09 14:23 ` [PATCH 2/4] iio: accel: mma8452: " Rajveer Chaudhari
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:23 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(). 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/bmc150-accel-core.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 42ccf0316ce5..9ae325cdfdd3 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"
@@ -1485,7 +1488,7 @@ static int bmc150_accel_buffer_postenable(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->watermark)
goto out;
@@ -1517,19 +1520,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] 10+ messages in thread
* [PATCH 2/4] iio: accel: mma8452: convert to guard(mutex)
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:23 ` Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 3/4] iio: accel: mma9551: " Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 4/4] iio: accel: sca3000: " Rajveer Chaudhari
3 siblings, 0 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:23 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.
Aligned headers in alphabatical order.
Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
---
drivers/iio/accel/mma8452.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 15172ba2972c..ae096e618810 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -18,21 +18,24 @@
* TODO: orientation events
*/
+#include <linux/cleanup.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.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))
@@ -597,36 +600,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] 10+ messages in thread
* [PATCH 3/4] iio: accel: mma9551: convert to guard(mutex)
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:23 ` [PATCH 2/4] iio: accel: mma8452: " Rajveer Chaudhari
@ 2026-03-09 14:23 ` Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 4/4] iio: accel: sca3000: " Rajveer Chaudhari
3 siblings, 0 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:23 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.
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] iio: accel: sca3000: convert to guard(mutex)
2026-03-09 14:23 [PATCH 0/4] iio: accel: convert to guard(mutex) Rajveer Chaudhari
` (2 preceding siblings ...)
2026-03-09 14:23 ` [PATCH 3/4] iio: accel: mma9551: " Rajveer Chaudhari
@ 2026-03-09 14:23 ` Rajveer Chaudhari
3 siblings, 0 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:23 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(). 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/sca3000.c | 115 ++++++++++++++++--------------------
1 file changed, 52 insertions(+), 63 deletions(-)
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 4a827be439a2..05c91dfbc6ab 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)
@@ -424,16 +427,16 @@ 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;
}
@@ -996,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
@@ -1011,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
@@ -1023,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);
}
/**
@@ -1110,11 +1113,11 @@ 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:
@@ -1134,7 +1137,7 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
ret = sca3000_read_ctrl_reg(st,
SCA3000_REG_CTRL_SEL_MD_CTRL);
if (ret < 0)
- goto error_ret;
+ return ret;
/* only supporting logical or's for now */
ret = !!(ret & sca3000_addresses[chan->address][2]);
}
@@ -1143,9 +1146,6 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
ret = -EINVAL;
}
-error_ret:
- mutex_unlock(&st->lock);
-
return ret;
}
@@ -1277,10 +1277,12 @@ 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,
@@ -1290,8 +1292,6 @@ int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
ret = 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;
}
@@ -1310,26 +1310,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)
@@ -1342,17 +1336,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,
+ return ret;
+
+ return 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;
}
static const struct iio_buffer_setup_ops sca3000_ring_setup_ops = {
@@ -1372,25 +1364,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
@@ -1398,17 +1391,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
@@ -1416,13 +1409,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 = {
@@ -1504,18 +1494,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,
+ 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)));
-error_ret:
- mutex_unlock(&st->lock);
- return ret;
}
static void sca3000_remove(struct spi_device *spi)
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
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
1 sibling, 0 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 14:34 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
On Mon, Mar 9, 2026 at 7:54 PM Rajveer Chaudhari
<rajveer.chaudhari.linux@gmail.com> wrote:
> @@ -1485,7 +1488,7 @@ static int bmc150_accel_buffer_postenable(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->watermark)
> goto out;
I am sorry I accidentally forgot to clean up goto and mutex_unlock in
bmc150_accel_buffer_postenable().
I will fix it in V2.
Thankyou,
Rajveer
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
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
1 sibling, 1 reply; 10+ messages in thread
From: Waqar Hameed @ 2026-03-09 14:35 UTC (permalink / raw)
To: Rajveer Chaudhari
Cc: jic23, dlechner, nuno.sa, andy, linusw, sakari.ailus,
harshit.m.mogalapalli, antoniu.miclaus, andrew.ijano, linux-iio,
linux-kernel
On Mon, Mar 09, 2026 at 19:53 +0530 Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> wrote:
> Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
> bmc150_accel_buffer_predisable(). This ensures the mutex is
> released on all return paths and allows returning directly
> without a goto label.
>
> Aligned headers in alphabatical order.
Never mix unrelated changes. This should be separate patches. Why? Think
about traceability (bisect etc.).
This comment applies to all other patches in the series as well. I'll
just state it here and wait for V2 before taking a deeper look.
To be honest, I'm not even sure if sorting the headers is a "valid"
patch. It's just cosmetics (and there seems to be no such code style
guidelines)...
[...]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
2026-03-09 14:35 ` Waqar Hameed
@ 2026-03-09 16:26 ` Andy Shevchenko
2026-03-09 16:48 ` Waqar Hameed
0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2026-03-09 16:26 UTC (permalink / raw)
To: Waqar Hameed
Cc: Rajveer Chaudhari, jic23, dlechner, nuno.sa, andy, linusw,
sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
andrew.ijano, linux-iio, linux-kernel
On Mon, Mar 09, 2026 at 03:35:58PM +0100, Waqar Hameed wrote:
> On Mon, Mar 09, 2026 at 19:53 +0530 Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com> wrote:
[...]
> > Aligned headers in alphabatical order.
>
> Never mix unrelated changes. This should be separate patches.
Yep, I only mentioned to place cleanup.h in the better place.
> Why? Think about traceability (bisect etc.).
It's all about maintenance and development. Easy to see where need to put
a new header if it's not present (also easier to find this at a glance).
> This comment applies to all other patches in the series as well. I'll
> just state it here and wait for V2 before taking a deeper look.
> To be honest, I'm not even sure if sorting the headers is a "valid"
> patch. It's just cosmetics (and there seems to be no such code style
> guidelines)...
It's valid when in a series (not as just for the sake of sorting). Here
it would make sense to have it as a precursor to find the best place for
a new header inclusion to place.
Guidelines here are still missing maintainer preferences for IIO subsystem.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
2026-03-09 16:26 ` Andy Shevchenko
@ 2026-03-09 16:48 ` Waqar Hameed
2026-03-09 17:25 ` Rajveer Chaudhari
0 siblings, 1 reply; 10+ messages in thread
From: Waqar Hameed @ 2026-03-09 16:48 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rajveer Chaudhari, jic23, dlechner, nuno.sa, andy, linusw,
sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
andrew.ijano, linux-iio, linux-kernel
On Mon, Mar 09, 2026 at 18:26 +0200 Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Mon, Mar 09, 2026 at 03:35:58PM +0100, Waqar Hameed wrote:
[...]
>> Why? Think about traceability (bisect etc.).
>
> It's all about maintenance and development. Easy to see where need to put
> a new header if it's not present (also easier to find this at a glance).
Totally agree (see below).
>
>> This comment applies to all other patches in the series as well. I'll
>> just state it here and wait for V2 before taking a deeper look.
>
>> To be honest, I'm not even sure if sorting the headers is a "valid"
>> patch. It's just cosmetics (and there seems to be no such code style
>> guidelines)...
>
> It's valid when in a series (not as just for the sake of sorting). Here
> it would make sense to have it as a precursor to find the best place for
> a new header inclusion to place.
>
> Guidelines here are still missing maintainer preferences for IIO subsystem.
Yeah, I guess that's kind of the issue here (or in general for kernel
developing). Every sub-system have their preference. You just have to
carefully navigate through all of this :)
Moreover, I always tend to sort the include header when creating a _new_
file (for the reason you stated above). `clang-format` does that
automatically for me, though you have to modify the
`.clang-format`-file:
diff --git a/.clang-format b/.clang-format
index 1cc151e2adcc5..f6631d03bd3f3 100644
--- a/.clang-format
+++ b/.clang-format
@@ -784,7 +784,7 @@ PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: false
-SortIncludes: false
+SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
The reason for the `false` value can be read in the last section "Extra
features/option" in `Documentation/dev-tools/clang-format.rst`.
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] iio: accel: bmc150: convert to guard(mutex)
2026-03-09 16:48 ` Waqar Hameed
@ 2026-03-09 17:25 ` Rajveer Chaudhari
0 siblings, 0 replies; 10+ messages in thread
From: Rajveer Chaudhari @ 2026-03-09 17:25 UTC (permalink / raw)
To: Waqar Hameed
Cc: Andy Shevchenko, jic23, dlechner, nuno.sa, andy, linusw,
sakari.ailus, harshit.m.mogalapalli, antoniu.miclaus,
andrew.ijano, linux-iio, linux-kernel
On Mon, Mar 9, 2026 at 10:18 PM Waqar Hameed <waqar.hameed@axis.com> wrote:
> Yeah, I guess that's kind of the issue here (or in general for kernel
> developing). Every sub-system have their preference. You just have to
> carefully navigate through all of this :)
Hello Waqar,
yes In one patch in another sub-system, Maintainers told me to keep
headers in alphabetical order.
so i thought it would be a good idea to arrange the headers
alphabetically here too.
Thanks,
Rajveer
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-03-09 17:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/4] iio: accel: mma9551: " Rajveer Chaudhari
2026-03-09 14:23 ` [PATCH 4/4] iio: accel: sca3000: " Rajveer Chaudhari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox