Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

CRIS: use generic atomic.h

CRIS can use asm-generic's atomic.h.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>

authored by

Rabin Vincent and committed by
Jesper Nilsson
e7db8a3c f6475111

+1 -165
-7
arch/cris/include/arch-v10/arch/atomic.h
··· 1 - #ifndef __ASM_CRIS_ARCH_ATOMIC__ 2 - #define __ASM_CRIS_ARCH_ATOMIC__ 3 - 4 - #define cris_atomic_save(addr, flags) local_irq_save(flags); 5 - #define cris_atomic_restore(addr, flags) local_irq_restore(flags); 6 - 7 - #endif
-8
arch/cris/include/arch-v32/arch/atomic.h
··· 1 - #ifndef __ASM_CRIS_ARCH_ATOMIC__ 2 - #define __ASM_CRIS_ARCH_ATOMIC__ 3 - 4 - #define cris_atomic_save(addr, flags) local_irq_save(flags); 5 - #define cris_atomic_restore(addr, flags) local_irq_restore(flags); 6 - 7 - #endif 8 -
+1 -1
arch/cris/include/asm/Kbuild
··· 1 - 1 + generic-y += atomic.h 2 2 generic-y += barrier.h 3 3 generic-y += clkdev.h 4 4 generic-y += cputime.h
-149
arch/cris/include/asm/atomic.h
··· 1 - /* $Id: atomic.h,v 1.3 2001/07/25 16:15:19 bjornw Exp $ */ 2 - 3 - #ifndef __ASM_CRIS_ATOMIC__ 4 - #define __ASM_CRIS_ATOMIC__ 5 - 6 - #include <linux/compiler.h> 7 - #include <linux/types.h> 8 - #include <asm/cmpxchg.h> 9 - #include <arch/atomic.h> 10 - #include <arch/system.h> 11 - #include <asm/barrier.h> 12 - 13 - /* 14 - * Atomic operations that C can't guarantee us. Useful for 15 - * resource counting etc.. 16 - */ 17 - 18 - #define ATOMIC_INIT(i) { (i) } 19 - 20 - #define atomic_read(v) ACCESS_ONCE((v)->counter) 21 - #define atomic_set(v,i) (((v)->counter) = (i)) 22 - 23 - /* These should be written in asm but we do it in C for now. */ 24 - 25 - #define ATOMIC_OP(op, c_op) \ 26 - static inline void atomic_##op(int i, volatile atomic_t *v) \ 27 - { \ 28 - unsigned long flags; \ 29 - cris_atomic_save(v, flags); \ 30 - v->counter c_op i; \ 31 - cris_atomic_restore(v, flags); \ 32 - } \ 33 - 34 - #define ATOMIC_OP_RETURN(op, c_op) \ 35 - static inline int atomic_##op##_return(int i, volatile atomic_t *v) \ 36 - { \ 37 - unsigned long flags; \ 38 - int retval; \ 39 - cris_atomic_save(v, flags); \ 40 - retval = (v->counter c_op i); \ 41 - cris_atomic_restore(v, flags); \ 42 - return retval; \ 43 - } 44 - 45 - #define ATOMIC_OPS(op, c_op) ATOMIC_OP(op, c_op) ATOMIC_OP_RETURN(op, c_op) 46 - 47 - ATOMIC_OPS(add, +=) 48 - ATOMIC_OPS(sub, -=) 49 - 50 - #undef ATOMIC_OPS 51 - #undef ATOMIC_OP_RETURN 52 - #undef ATOMIC_OP 53 - 54 - #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) 55 - 56 - static inline int atomic_sub_and_test(int i, volatile atomic_t *v) 57 - { 58 - int retval; 59 - unsigned long flags; 60 - cris_atomic_save(v, flags); 61 - retval = (v->counter -= i) == 0; 62 - cris_atomic_restore(v, flags); 63 - return retval; 64 - } 65 - 66 - static inline void atomic_inc(volatile atomic_t *v) 67 - { 68 - unsigned long flags; 69 - cris_atomic_save(v, flags); 70 - (v->counter)++; 71 - cris_atomic_restore(v, flags); 72 - } 73 - 74 - static inline void atomic_dec(volatile atomic_t *v) 75 - { 76 - unsigned long flags; 77 - cris_atomic_save(v, flags); 78 - (v->counter)--; 79 - cris_atomic_restore(v, flags); 80 - } 81 - 82 - static inline int atomic_inc_return(volatile atomic_t *v) 83 - { 84 - unsigned long flags; 85 - int retval; 86 - cris_atomic_save(v, flags); 87 - retval = ++(v->counter); 88 - cris_atomic_restore(v, flags); 89 - return retval; 90 - } 91 - 92 - static inline int atomic_dec_return(volatile atomic_t *v) 93 - { 94 - unsigned long flags; 95 - int retval; 96 - cris_atomic_save(v, flags); 97 - retval = --(v->counter); 98 - cris_atomic_restore(v, flags); 99 - return retval; 100 - } 101 - static inline int atomic_dec_and_test(volatile atomic_t *v) 102 - { 103 - int retval; 104 - unsigned long flags; 105 - cris_atomic_save(v, flags); 106 - retval = --(v->counter) == 0; 107 - cris_atomic_restore(v, flags); 108 - return retval; 109 - } 110 - 111 - static inline int atomic_inc_and_test(volatile atomic_t *v) 112 - { 113 - int retval; 114 - unsigned long flags; 115 - cris_atomic_save(v, flags); 116 - retval = ++(v->counter) == 0; 117 - cris_atomic_restore(v, flags); 118 - return retval; 119 - } 120 - 121 - static inline int atomic_cmpxchg(atomic_t *v, int old, int new) 122 - { 123 - int ret; 124 - unsigned long flags; 125 - 126 - cris_atomic_save(v, flags); 127 - ret = v->counter; 128 - if (likely(ret == old)) 129 - v->counter = new; 130 - cris_atomic_restore(v, flags); 131 - return ret; 132 - } 133 - 134 - #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 135 - 136 - static inline int __atomic_add_unless(atomic_t *v, int a, int u) 137 - { 138 - int ret; 139 - unsigned long flags; 140 - 141 - cris_atomic_save(v, flags); 142 - ret = v->counter; 143 - if (ret != u) 144 - v->counter += a; 145 - cris_atomic_restore(v, flags); 146 - return ret; 147 - } 148 - 149 - #endif