@@ -59,4 +59,22 @@ rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f)
}
#endif /* < 4.20 */
+#ifndef rcu_swap_protected
+/**
+ * rcu_swap_protected() - swap an RCU and a regular pointer
+ * @rcu_ptr: RCU pointer
+ * @ptr: regular pointer
+ * @c: the conditions under which the dereference will take place
+ *
+ * Perform swap(@rcu_ptr, @ptr) where @rcu_ptr is an RCU-annotated pointer and
+ * @c is the argument that is passed to the rcu_dereference_protected() call
+ * used to read that pointer.
+ */
+#define rcu_swap_protected(rcu_ptr, ptr, c) do { \
+ typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \
+ rcu_assign_pointer((rcu_ptr), (ptr)); \
+ (ptr) = __tmp; \
+} while (0)
+#endif
+
#endif /* __BACKPORT_LINUX_RCUPDATE_H */
Backport rcu_swap_protected() from upstream Linux commit 26e3e3cb0560 ("scsi: rcu: Introduce rcu_swap_protected()"). This is used by the mt76 driver. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- backport/backport-include/linux/rcupdate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)