* [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* Re: [PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking
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
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-04-11 8:09 UTC (permalink / raw)
To: Advaith Neelacantan
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Greg Kroah-Hartman,
linux-iio, linux-staging, linux-kernel
On Sat, Apr 11, 2026 at 12:55:04PM +0530, Advaith Neelacantan wrote:
> 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>
The original code works fine.
We're not accepting this sort of patch for old code unless it fixes
a bug.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking
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
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-11 8:53 UTC (permalink / raw)
To: Advaith Neelacantan
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-staging, linux-kernel
On Sat, Apr 11, 2026 at 12:55:04PM +0530, Advaith Neelacantan wrote:
> Replace mutex lock/unlock pairs with
>
> guard(mutex) for automatic scope-based locking.
>
> Simplifies code by removing need to manually unlock.
Only use guard() for new code, no need to change existing code for that
at all.
thanks,
greg k-h
^ permalink raw reply [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