summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Sa <nuno.sa@analog.com>2024-06-18 16:32:06 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-06-25 23:04:49 +0300
commite6cab1ad9769a6b03dd1ba7ace106c36de85b1a8 (patch)
treefef04b5fb317eb185556f3b0a2d944f242969a21
parentd305b7f34ee11c4901b8da150b641bcffbd3e951 (diff)
downloadlinux-e6cab1ad9769a6b03dd1ba7ace106c36de85b1a8.tar.xz
iio: imu: adis: add cleanup based lock helpers
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> Link: https://patch.msgid.link/20240618-dev-iio-adis-cleanup-v1-3-bd93ce7845c7@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--include/linux/iio/imu/adis.h4
1 files changed, 4 insertions, 0 deletions
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);