The 'treelock' parameter is type-checked to be of spinlock_t. The lock
to protect the tree might be something else, though. E.g. the hwspinlock
subsystem uses a mutex. 'treelock' is simply passed onto
lockdep_is_held() which supports way more lock types by using a #define
instead of an inline function. Use the same approach for
radix_tree_deref_slot_protected() to support more lock types, too.

Signed-off-by: Wolfram Sang <[email protected]>
---
 include/linux/radix-tree.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index b8997f07b2d4..a07e5a51eaf9 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -182,18 +182,16 @@ static inline void *radix_tree_deref_slot(void __rcu 
**slot)
 /**
  * radix_tree_deref_slot_protected - dereference a slot with tree lock held
  * @slot: slot pointer, returned by radix_tree_lookup_slot
- * @treelock: pointer to the spinlock protecting the tree
+ * @treelock: pointer to the lock protecting the tree. Any lock type supported
+ *            by lockdep_is_held() can be used
  *
  * Similar to radix_tree_deref_slot.  The caller does not hold the RCU read
  * lock but it must hold the tree lock to prevent parallel updates.
  *
  * Return: entry stored in that slot.
  */
-static inline void *radix_tree_deref_slot_protected(void __rcu **slot,
-                                                       spinlock_t *treelock)
-{
-       return rcu_dereference_protected(*slot, lockdep_is_held(treelock));
-}
+#define radix_tree_deref_slot_protected(slot, treelock) \
+       rcu_dereference_protected(*(slot), lockdep_is_held(treelock))
 
 /**
  * radix_tree_deref_retry      - check radix_tree_deref_slot
-- 
2.47.3


Reply via email to