When used without a context, dma_resv are no different from regular locks. Define guards so we can use the guard-syntactic sugars for explicit/implicit scoped locks.
Signed-off-by: Boris Brezillon boris.brezillon@collabora.com --- include/linux/dma-resv.h | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index c5ab6fd9ebe8..e559b1811ca3 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -40,6 +40,7 @@ #define _LINUX_RESERVATION_H
#include <linux/ww_mutex.h> +#include <linux/cleanup.h> #include <linux/dma-fence.h> #include <linux/slab.h> #include <linux/seqlock.h> @@ -484,4 +485,8 @@ void dma_resv_set_deadline(struct dma_resv *obj, enum dma_resv_usage usage, bool dma_resv_test_signaled(struct dma_resv *obj, enum dma_resv_usage usage); void dma_resv_describe(struct dma_resv *obj, struct seq_file *seq);
+DEFINE_GUARD(dma_resv, struct dma_resv *, dma_resv_lock(_T, NULL), dma_resv_unlock(_T)); +DEFINE_GUARD_COND(dma_resv, _intr, dma_resv_lock_interruptible(_T, NULL), !_RET); +DEFINE_GUARD_COND(dma_resv, _try, dma_resv_trylock(_T)); + #endif /* _LINUX_RESERVATION_H */