[PATCH 2/3] iio: accel: adxl313_core: use guard() to release mutex

From: Sanjay Chitroda

Date: Thu Apr 16 2026 - 01:18:23 EST


From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>

Replace explicit mutex_lock() and mutex_unlock() with the guard() macro
for cleaner and safer mutex handling.

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
---
drivers/iio/accel/adxl313_core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index 2ca4ce90cd86..339570701083 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -356,19 +356,15 @@ static int adxl313_read_axis(struct adxl313_data *data,
{
int ret;

- mutex_lock(&data->lock);
+ guard(mutex)(&data->lock);

ret = regmap_bulk_read(data->regmap,
ADXL313_REG_DATA_AXIS(chan->address),
&data->transf_buf, sizeof(data->transf_buf));
if (ret)
- goto unlock_ret;
-
- ret = le16_to_cpu(data->transf_buf);
+ return ret;

-unlock_ret:
- mutex_unlock(&data->lock);
- return ret;
+ return le16_to_cpu(data->transf_buf);
}

static int adxl313_read_freq_avail(struct iio_dev *indio_dev,
--
2.34.1