[Sound-open-firmware] [PATCH] atomic: add atomic_read and atomic_set

Liam Girdwood liam.r.girdwood at linux.intel.com
Mon Jun 4 13:03:43 CEST 2018


From: Tomasz Lauda <tomasz.lauda at linux.intel.com>

This patch adds atomic_read and atomic_set methods.
Also includes xtensa implementation of those methods.

Signed-off-by: Tomasz Lauda <tomasz.lauda at linux.intel.com>
---
 src/arch/xtensa/include/arch/atomic.h | 12 +++++++++++-
 src/include/sof/atomic.h              | 10 ++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/arch/xtensa/include/arch/atomic.h b/src/arch/xtensa/include/arch/atomic.h
index 80c4522..aadc6db 100644
--- a/src/arch/xtensa/include/arch/atomic.h
+++ b/src/arch/xtensa/include/arch/atomic.h
@@ -39,11 +39,21 @@ typedef struct {
 	volatile int32_t value;
 } atomic_t;
 
-static inline void arch_atomic_init(atomic_t *a, int32_t value)
+static inline int32_t arch_atomic_read(const atomic_t *a)
+{
+	return (*(volatile int32_t *)&a->value);
+}
+
+static inline void arch_atomic_set(atomic_t *a, int32_t value)
 {
 	a->value = value;
 }
 
+static inline void arch_atomic_init(atomic_t *a, int32_t value)
+{
+	arch_atomic_set(a, value);
+}
+
 static inline void arch_atomic_add(atomic_t *a, int32_t value)
 {
 	int32_t result, current;
diff --git a/src/include/sof/atomic.h b/src/include/sof/atomic.h
index b26b701..6561215 100644
--- a/src/include/sof/atomic.h
+++ b/src/include/sof/atomic.h
@@ -40,6 +40,16 @@ static inline void atomic_init(atomic_t *a, int32_t value)
 	arch_atomic_init(a, value);
 }
 
+static inline int32_t atomic_read(const atomic_t *a)
+{
+	return arch_atomic_read(a);
+}
+
+static inline void atomic_set(atomic_t *a, int32_t value)
+{
+	arch_atomic_set(a, value);
+}
+
 static inline void atomic_add(atomic_t *a, int32_t value)
 {
 	arch_atomic_add(a, value);
-- 
2.17.0



More information about the Sound-open-firmware mailing list