[PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking

Advaith Neelacantan
2026-04-11T07:25:37Z

Replace mutex lock/unlock pairs with

guard(mutex) for automatic scope-based locking.

Simplifies code by removing need to manually unlock.

Signed-off-by: Advaith Neelacantan <advaith.neelacantan@gmail.com>
---
drivers/staging/iio/frequency/ad9832.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index b87ea1781..73c47a049 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -181,7 +181,7 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr,
if (ret)
goto error_ret;

- mutex_lock(&st->lock);
+ guard(mutex)(&st->lock);
switch ((u32)this_attr->address) {
case AD9832_FREQ0HM:
case AD9832_FREQ1HM:
@@ -239,7 +239,6 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr,
default:
ret = -ENODEV;
}
- mutex_unlock(&st->lock);

error_ret:
return ret ? ret : len;
--
2.51.0