From: Nuno Sa <nuno.sa@analog.com>
To: <linux-iio@vger.kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH 3/9] iio: imu: adis: add cleanup based lock helpers
Date: Tue, 18 Jun 2024 15:32:06 +0200 [thread overview]
Message-ID: <20240618-dev-iio-adis-cleanup-v1-3-bd93ce7845c7@analog.com> (raw)
In-Reply-To: <20240618-dev-iio-adis-cleanup-v1-0-bd93ce7845c7@analog.com>
Add two new lock helpers that make use of the cleanup guard() and
scoped_guard() macros. Thus, users won't have to worry about unlocking
which is less prone to errors and allows for simpler error paths.
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
include/linux/iio/imu/adis.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
index 93dad627378f..bc7332d12c44 100644
--- a/include/linux/iio/imu/adis.h
+++ b/include/linux/iio/imu/adis.h
@@ -403,6 +403,10 @@ static inline int adis_check_status(struct adis *adis)
return __adis_check_status(adis);
}
+#define adis_dev_auto_lock(adis) guard(mutex)(&(adis)->state_lock)
+#define adis_dev_auto_scoped_lock(adis) \
+ scoped_guard(mutex, &(adis)->state_lock)
+
static inline void adis_dev_lock(struct adis *adis)
{
mutex_lock(&adis->state_lock);
--
2.45.2
next prev parent reply other threads:[~2024-06-18 13:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 13:32 [PATCH 0/9] iio: imu: adis: make use the cleanup.h magic Nuno Sa
2024-06-18 13:32 ` [PATCH 1/9] iio: imu: adis_buffer: split trigger handling Nuno Sa
2024-06-23 16:03 ` Jonathan Cameron
2024-06-23 16:15 ` Jonathan Cameron
2024-06-18 13:32 ` [PATCH 2/9] iio: imu: adis: move to the cleanup magic Nuno Sa
2024-06-18 13:32 ` Nuno Sa [this message]
2024-06-18 13:32 ` [PATCH 4/9] iio: gyro: adis16260: make use of the new lock helpers Nuno Sa
2024-06-18 13:32 ` [PATCH 5/9] " Nuno Sa
2024-06-18 13:32 ` [PATCH 6/9] iio: imu: adis16400: " Nuno Sa
2024-06-18 13:32 ` [PATCH 7/9] iio: imu: adis16480: " Nuno Sa
2024-06-18 13:32 ` [PATCH 8/9] iio: imu: adis16475: " Nuno Sa
2024-06-23 16:16 ` Jonathan Cameron
2024-06-18 13:32 ` [PATCH 9/9] iio: imu: adis: remove legacy " Nuno Sa
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=20240618-dev-iio-adis-cleanup-v1-3-bd93ce7845c7@analog.com \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).