[kvm-unit-tests,v2,3/3] x86: use asm-generic spinlock

Message ID 20170515110348.30449-4-david@redhat.com
State Accepted
Headers show

Commit Message

David Hildenbrand May 15, 2017, 11:03 a.m.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 lib/x86/asm/spinlock.h |  7 +------
 lib/x86/smp.c          | 16 ----------------
 2 files changed, 1 insertion(+), 22 deletions(-)

Patch

diff --git a/lib/x86/asm/spinlock.h b/lib/x86/asm/spinlock.h
index 4b0cb33..692020c 100644
--- a/lib/x86/asm/spinlock.h
+++ b/lib/x86/asm/spinlock.h
@@ -1,11 +1,6 @@ 
 #ifndef __ASM_SPINLOCK_H
 #define __ASM_SPINLOCK_H
 
-struct spinlock {
-    int v;
-};
-
-void spin_lock(struct spinlock *lock);
-void spin_unlock(struct spinlock *lock);
+#include <asm-generic/spinlock.h>
 
 #endif
diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index 1eb49f2..4bdbeae 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -43,22 +43,6 @@  asm (
 #endif
      );
 
-void spin_lock(struct spinlock *lock)
-{
-    int v = 1;
-
-    do {
-	asm volatile ("xchg %1, %0" : "+m"(lock->v), "+r"(v));
-    } while (v);
-    asm volatile ("" : : : "memory");
-}
-
-void spin_unlock(struct spinlock *lock)
-{
-    asm volatile ("" : : : "memory");
-    lock->v = 0;
-}
-
 int cpu_count(void)
 {
     return _cpu_count;