[PATCH 01/18] x86: expose spin_lock/unlock to lib code

Andrew Jones
2015-02-01T18:34:56Z

Move the spin_lock/unlock declarations to lib/x86/asm/spinlock.h,
allowing lib code, e.g. lib/report.c, to use spinlocks.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/x86/asm/spinlock.h | 11 +++++++++++
lib/x86/smp.h | 7 +------
2 files changed, 12 insertions(+), 6 deletions(-)
create mode 100644 lib/x86/asm/spinlock.h

diff --git a/lib/x86/asm/spinlock.h b/lib/x86/asm/spinlock.h
new file mode 100644
index 0000000000000..4b0cb331c048b
--- /dev/null
+++ b/lib/x86/asm/spinlock.h
@@ -0,0 +1,11 @@
+#ifndef __ASM_SPINLOCK_H
+#define __ASM_SPINLOCK_H
+
+struct spinlock {
+ int v;
+};
+
+void spin_lock(struct spinlock *lock);
+void spin_unlock(struct spinlock *lock);
+
+#endif
diff --git a/lib/x86/smp.h b/lib/x86/smp.h
index df5fdba9b9288..566018f49ba31 100644
--- a/lib/x86/smp.h
+++ b/lib/x86/smp.h
@@ -1,21 +1,16 @@
#ifndef __SMP_H
#define __SMP_H
+#include <asm/spinlock.h>

#define mb() asm volatile("mfence":::"memory")
#define rmb() asm volatile("lfence":::"memory")
#define wmb() asm volatile("sfence" ::: "memory")

-struct spinlock {
- int v;
-};
-
void smp_init(void);

int cpu_count(void);
int smp_id(void);
void on_cpu(int cpu, void (*function)(void *data), void *data);
void on_cpu_async(int cpu, void (*function)(void *data), void *data);
-void spin_lock(struct spinlock *lock);
-void spin_unlock(struct spinlock *lock);

#endif
--
1.9.3