]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/asm-m68knommu/system.h
Add cmpxchg_local to m68knommu
[linux-2.6-omap-h63xx.git] / include / asm-m68knommu / system.h
index 5e5ed18bb78f54185da3d69ecfc0b1e9fd2373f7..039ab3f817328ec639cc2a59ea7a9581463e6623 100644 (file)
@@ -104,8 +104,7 @@ asmlinkage void resume(void);
 #define mb()   asm volatile (""   : : :"memory")
 #define rmb()  asm volatile (""   : : :"memory")
 #define wmb()  asm volatile (""   : : :"memory")
-#define set_rmb(var, value)    do { xchg(&var, value); } while (0)
-#define set_mb(var, value)     set_rmb(var, value)
+#define set_mb(var, value) do { xchg(&var, value); } while (0)
 
 #ifdef CONFIG_SMP
 #define smp_mb()       mb()
@@ -187,42 +186,19 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
 }
 #endif
 
+#include <asm-generic/cmpxchg-local.h>
+
 /*
- * Atomic compare and exchange.  Compare OLD with MEM, if identical,
- * store NEW in MEM.  Return the initial value in MEM.  Success is
- * indicated by comparing RETURN with OLD.
+ * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
+ * them available.
  */
-#define __HAVE_ARCH_CMPXCHG    1
-
-static __inline__ unsigned long
-cmpxchg(volatile int *p, int old, int new)
-{
-       unsigned long flags;
-       int prev;
-
-       local_irq_save(flags);
-       if ((prev = *p) == old)
-               *p = new;
-       local_irq_restore(flags);
-       return(prev);
-}
-
+#define cmpxchg_local(ptr, o, n)                                              \
+       ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+                       (unsigned long)(n), sizeof(*(ptr))))
+#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
-#ifdef CONFIG_M68332
-#define HARD_RESET_NOW() ({            \
-        local_irq_disable();           \
-        asm("                          \
-       movew   #0x0000, 0xfffa6a;      \
-        reset;                         \
-        /*movew #0x1557, 0xfffa44;*/   \
-        /*movew #0x0155, 0xfffa46;*/   \
-        moveal #0, %a0;                        \
-        movec %a0, %vbr;               \
-        moveal 0, %sp;                 \
-        moveal 4, %a0;                 \
-        jmp (%a0);                     \
-        ");                            \
-})
+#ifndef CONFIG_SMP
+#include <asm-generic/cmpxchg.h>
 #endif
 
 #if defined( CONFIG_M68328 ) || defined( CONFIG_M68EZ328 ) || \
@@ -253,8 +229,7 @@ cmpxchg(volatile int *p, int old, int new)
         ");                            \
 })
 #elif defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
-      defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
-      defined(CONFIG_CLEOPATRA)
+      defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA)
 #define HARD_RESET_NOW() ({            \
         asm("                          \
        movew #0x2700, %sr;             \
@@ -296,7 +271,7 @@ cmpxchg(volatile int *p, int old, int new)
 ({                                             \
        unsigned char volatile *reset;          \
        asm("move.w     #0x2700, %sr");         \
-       reset = ((volatile unsigned short *)(MCF_IPSBAR + 0x110000));   \
+       reset = ((volatile unsigned char *)(MCF_IPSBAR + 0x110000));    \
        while(1)                                \
        *reset |= (0x01 << 7);\
 })
@@ -318,7 +293,7 @@ cmpxchg(volatile int *p, int old, int new)
 ({                                     \
        unsigned char volatile *reset;  \
        asm("move.w     #0x2700, %sr"); \
-       reset = ((volatile unsigned short *)(MCF_IPSBAR + 0xA0000));    \
+       reset = ((volatile unsigned char *)(MCF_IPSBAR + 0xA0000));     \
        while(1)                        \
                *reset |= 0x80;         \
 })