From 18f26958544783b0f30210c41fc0c0da11b8d9a4 Mon Sep 17 00:00:00 2001 From: Guixin Liu Date: Wed, 16 Sep 2026 10:54:52 +0800 Subject: driver core: Add conditional guard support for device_trylock() Introduce a conditional guard version of device_trylock() for scenarios that must not block on the device lock. device_trylock() returns 1 on success like mutex_trylock(), so the default binary condition applies and ACQUIRE_ERR() reports -EBUSY on contention. Suggested-by: Shaikh Kamaluddin Reviewed-by: Jonathan Cameron Signed-off-by: Guixin Liu Acked-by: Greg Kroah-Hartman Reviewed-by: Dave Jiang Link: https://patch.msgid.link/20260916025453.3532614-2-kanie@linux.alibaba.com Signed-off-by: Dave Jiang --- include/linux/device.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux') diff --git a/include/linux/device.h b/include/linux/device.h index aee79fd6b32b..a8d6cf76d137 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1121,6 +1121,7 @@ static inline void device_unlock(struct device *dev) DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) DEFINE_GUARD_COND(device, _intr, device_lock_interruptible(_T), _RET == 0) +DEFINE_GUARD_COND(device, _try, device_trylock(_T)) static inline void device_lock_assert(struct device *dev) { -- cgit v1.2.3