From: Advaith Neelacantan <advaith.neelacantan@gmail.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: "Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
"Advaith Neelacantan" <advaith.neelacantan@gmail.com>
Subject: [PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking
Date: Sat, 11 Apr 2026 12:55:04 +0530 [thread overview]
Message-ID: <20260411072503.106621-2-advaith.neelacantan@gmail.com> (raw)
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
next reply other threads:[~2026-04-11 7:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-11 7:25 Advaith Neelacantan [this message]
2026-04-11 8:09 ` [PATCH] staging: iio: frequency: ad9832: use guard(mutex) for locking Dan Carpenter
2026-04-11 8:53 ` Greg Kroah-Hartman
2026-04-14 12:55 ` kernel test robot
2026-04-20 13:06 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260411072503.106621-2-advaith.neelacantan@gmail.com \
--to=advaith.neelacantan@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox