Commit e6cab1ad authored by Nuno Sa's avatar Nuno Sa Committed by Jonathan Cameron

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: default avatarNuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240618-dev-iio-adis-cleanup-v1-3-bd93ce7845c7@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent d305b7f3
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment