diff options
author | Rabin Vincent <rabin@rab.in> | 2015-02-19 11:53:33 -0500 |
---|---|---|
committer | Jesper Nilsson <jespern@axis.com> | 2015-03-25 05:55:35 -0400 |
commit | f64751118b07579c7ebb7935b6fd8cc8e2c3291a (patch) | |
tree | 041fef8fbec34172fb66d86e07585cbef7f19a63 /arch/cris/include/asm/bitops.h | |
parent | 3c2165f807570c936b8ed6714edff1ef44def50a (diff) |
CRIS: use generic atomic bitops
The generic atomic bitops are the same as the CRIS-specific ones.
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
Diffstat (limited to 'arch/cris/include/asm/bitops.h')
-rw-r--r-- | arch/cris/include/asm/bitops.h | 111 |
1 files changed, 1 insertions, 110 deletions
diff --git a/arch/cris/include/asm/bitops.h b/arch/cris/include/asm/bitops.h index bd49a546f4f5..8062cb52d343 100644 --- a/arch/cris/include/asm/bitops.h +++ b/arch/cris/include/asm/bitops.h | |||
@@ -19,119 +19,10 @@ | |||
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | #include <arch/bitops.h> | 21 | #include <arch/bitops.h> |
22 | #include <linux/atomic.h> | ||
23 | #include <linux/compiler.h> | 22 | #include <linux/compiler.h> |
24 | #include <asm/barrier.h> | 23 | #include <asm/barrier.h> |
25 | 24 | ||
26 | /* | 25 | #include <asm-generic/bitops/atomic.h> |
27 | * set_bit - Atomically set a bit in memory | ||
28 | * @nr: the bit to set | ||
29 | * @addr: the address to start counting from | ||
30 | * | ||
31 | * This function is atomic and may not be reordered. See __set_bit() | ||
32 | * if you do not require the atomic guarantees. | ||
33 | * Note that @nr may be almost arbitrarily large; this function is not | ||
34 | * restricted to acting on a single-word quantity. | ||
35 | */ | ||
36 | |||
37 | #define set_bit(nr, addr) (void)test_and_set_bit(nr, addr) | ||
38 | |||
39 | /* | ||
40 | * clear_bit - Clears a bit in memory | ||
41 | * @nr: Bit to clear | ||
42 | * @addr: Address to start counting from | ||
43 | * | ||
44 | * clear_bit() is atomic and may not be reordered. However, it does | ||
45 | * not contain a memory barrier, so if it is used for locking purposes, | ||
46 | * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() | ||
47 | * in order to ensure changes are visible on other processors. | ||
48 | */ | ||
49 | |||
50 | #define clear_bit(nr, addr) (void)test_and_clear_bit(nr, addr) | ||
51 | |||
52 | /* | ||
53 | * change_bit - Toggle a bit in memory | ||
54 | * @nr: Bit to change | ||
55 | * @addr: Address to start counting from | ||
56 | * | ||
57 | * change_bit() is atomic and may not be reordered. | ||
58 | * Note that @nr may be almost arbitrarily large; this function is not | ||
59 | * restricted to acting on a single-word quantity. | ||
60 | */ | ||
61 | |||
62 | #define change_bit(nr, addr) (void)test_and_change_bit(nr, addr) | ||
63 | |||
64 | /** | ||
65 | * test_and_set_bit - Set a bit and return its old value | ||
66 | * @nr: Bit to set | ||
67 | * @addr: Address to count from | ||
68 | * | ||
69 | * This operation is atomic and cannot be reordered. | ||
70 | * It also implies a memory barrier. | ||
71 | */ | ||
72 | |||
73 | static inline int test_and_set_bit(int nr, volatile unsigned long *addr) | ||
74 | { | ||
75 | unsigned int mask, retval; | ||
76 | unsigned long flags; | ||
77 | unsigned int *adr = (unsigned int *)addr; | ||
78 | |||
79 | adr += nr >> 5; | ||
80 | mask = 1 << (nr & 0x1f); | ||
81 | cris_atomic_save(addr, flags); | ||
82 | retval = (mask & *adr) != 0; | ||
83 | *adr |= mask; | ||
84 | cris_atomic_restore(addr, flags); | ||
85 | return retval; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * test_and_clear_bit - Clear a bit and return its old value | ||
90 | * @nr: Bit to clear | ||
91 | * @addr: Address to count from | ||
92 | * | ||
93 | * This operation is atomic and cannot be reordered. | ||
94 | * It also implies a memory barrier. | ||
95 | */ | ||
96 | |||
97 | static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) | ||
98 | { | ||
99 | unsigned int mask, retval; | ||
100 | unsigned long flags; | ||
101 | unsigned int *adr = (unsigned int *)addr; | ||
102 | |||
103 | adr += nr >> 5; | ||
104 | mask = 1 << (nr & 0x1f); | ||
105 | cris_atomic_save(addr, flags); | ||
106 | retval = (mask & *adr) != 0; | ||
107 | *adr &= ~mask; | ||
108 | cris_atomic_restore(addr, flags); | ||
109 | return retval; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * test_and_change_bit - Change a bit and return its old value | ||
114 | * @nr: Bit to change | ||
115 | * @addr: Address to count from | ||
116 | * | ||
117 | * This operation is atomic and cannot be reordered. | ||
118 | * It also implies a memory barrier. | ||
119 | */ | ||
120 | |||
121 | static inline int test_and_change_bit(int nr, volatile unsigned long *addr) | ||
122 | { | ||
123 | unsigned int mask, retval; | ||
124 | unsigned long flags; | ||
125 | unsigned int *adr = (unsigned int *)addr; | ||
126 | adr += nr >> 5; | ||
127 | mask = 1 << (nr & 0x1f); | ||
128 | cris_atomic_save(addr, flags); | ||
129 | retval = (mask & *adr) != 0; | ||
130 | *adr ^= mask; | ||
131 | cris_atomic_restore(addr, flags); | ||
132 | return retval; | ||
133 | } | ||
134 | |||
135 | #include <asm-generic/bitops/non-atomic.h> | 26 | #include <asm-generic/bitops/non-atomic.h> |
136 | 27 | ||
137 | /* | 28 | /* |