Merge remote-tracking branch 'asoc/topic/pcm5102a' into asoc-next
[linux-2.6-block.git] / include / asm-generic / bitops / lock.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_GENERIC_BITOPS_LOCK_H_
3 #define _ASM_GENERIC_BITOPS_LOCK_H_
4
5 /**
6  * test_and_set_bit_lock - Set a bit and return its old value, for lock
7  * @nr: Bit to set
8  * @addr: Address to count from
9  *
10  * This operation is atomic and provides acquire barrier semantics if
11  * the returned value is 0.
12  * It can be used to implement bit locks.
13  */
14 #define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr)
15
16 /**
17  * clear_bit_unlock - Clear a bit in memory, for unlock
18  * @nr: the bit to set
19  * @addr: the address to start counting from
20  *
21  * This operation is atomic and provides release barrier semantics.
22  */
23 #define clear_bit_unlock(nr, addr)      \
24 do {                                    \
25         smp_mb__before_atomic();        \
26         clear_bit(nr, addr);            \
27 } while (0)
28
29 /**
30  * __clear_bit_unlock - Clear a bit in memory, for unlock
31  * @nr: the bit to set
32  * @addr: the address to start counting from
33  *
34  * A weaker form of clear_bit_unlock() as used by __bit_lock_unlock(). If all
35  * the bits in the word are protected by this lock some archs can use weaker
36  * ops to safely unlock.
37  *
38  * See for example x86's implementation.
39  */
40 #define __clear_bit_unlock(nr, addr)    \
41 do {                                    \
42         smp_mb__before_atomic();        \
43         clear_bit(nr, addr);            \
44 } while (0)
45
46 #endif /* _ASM_GENERIC_BITOPS_LOCK_H_ */
47