diff mbox series

[3/9] iio: imu: adis: add cleanup based lock helpers

Message ID 20240618-dev-iio-adis-cleanup-v1-3-bd93ce7845c7@analog.com (mailing list archive)
State Accepted
Headers show
Series iio: imu: adis: make use the cleanup.h magic | expand

Commit Message

Nuno Sá June 18, 2024, 1:32 p.m. UTC
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 mbox series


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)