aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2020-03-12 11:18:40 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2020-03-19 19:40:43 +0100
commitb0656050457ef9ee8bebb40c3f826e77cd209a06 (patch)
treefd480cd85b47beb2cbd5f8ed6363ecfa8f55da2e
parentd97302fd5b16a90bca09682df8696895fedf06b1 (diff)
downloadbackports-b0656050457ef9ee8bebb40c3f826e77cd209a06.tar.gz
backports: rcupdate.h: Add rcu_swap_protected()
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>
-rw-r--r--backport/backport-include/linux/rcupdate.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/backport/backport-include/linux/rcupdate.h b/backport/backport-include/linux/rcupdate.h
index cec4b3e8..db501007 100644
--- a/backport/backport-include/linux/rcupdate.h
+++ b/backport/backport-include/linux/rcupdate.h
@@ -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 */