@@ -11,6 +11,7 @@
#include <linux/bitmap.h>
#include <linux/bug.h>
+#include <linux/cleanup.h>
#include <linux/compiler.h>
#include <linux/gfp.h>
#include <linux/kconfig.h>
@@ -1883,4 +1884,19 @@ static inline void *xas_next(struct xa_state *xas)
return xa_entry(xas->xa, node, xas->xa_offset);
}
+DEFINE_GUARD(xa_lock, struct xarray *,
+ xa_lock(_T),
+ xa_unlock(_T))
+DEFINE_GUARD(xa_lock_bh, struct xarray *,
+ xa_lock_bh(_T),
+ xa_unlock_bh(_T))
+DEFINE_GUARD(xa_lock_irq, struct xarray *,
+ xa_lock_irq(_T),
+ xa_unlock_irq(_T))
+DEFINE_GUARD_COND(xa_lock, _try, xa_trylock(_T))
+DEFINE_LOCK_GUARD_1(xa_lock_irqsave, struct xarray,
+ xa_lock_irqsave(_T->lock, _T->flags),
+ xa_unlock_irqrestore(_T->lock, _T->flags),
+ unsigned long flags)
+
#endif /* _LINUX_XARRAY_H */
Add DEFINE_GUARD definitions so that xa_lock can be used with guard() or scoped_guard(). Signed-off-by: Michal Schmidt <mschmidt@redhat.com> --- include/linux/xarray.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)