projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d305b7f
)
iio: imu: adis: add cleanup based lock helpers
author
Nuno Sa
<nuno.sa@analog.com>
Tue, 18 Jun 2024 13:32:06 +0000
(15:32 +0200)
committer
Jonathan Cameron
<Jonathan.Cameron@huawei.com>
Tue, 25 Jun 2024 20:04:49 +0000
(21:04 +0100)
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>
include/linux/iio/imu/adis.h
patch
|
blob
|
blame
|
history
diff --git
a/include/linux/iio/imu/adis.h
b/include/linux/iio/imu/adis.h
index 93dad627378fd6e05ca8b70678c65da654f330c1..bc7332d12c44039aa3f848811c880a6a33007fc2 100644
(file)
--- 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);