public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: iio: frequency: ad9832:  use guard(mutex) for locking
@ 2026-04-11  7:25 Advaith Neelacantan
  2026-04-11  8:09 ` Dan Carpenter
  2026-04-11  8:53 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Advaith Neelacantan @ 2026-04-11  7:25 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Greg Kroah-Hartman, linux-iio, linux-staging,
	linux-kernel, Advaith Neelacantan

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


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

end of thread, other threads:[~2026-04-11  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11  7:25 [PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking Advaith Neelacantan
2026-04-11  8:09 ` Dan Carpenter
2026-04-11  8:53 ` Greg Kroah-Hartman

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