]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/asm-generic/bitops/lock.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / include / asm-generic / bitops / lock.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
26333576
NP
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.
11 * It can be used to implement bit locks.
12 */
13#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr)
14
15/**
16 * clear_bit_unlock - Clear a bit in memory, for unlock
17 * @nr: the bit to set
18 * @addr: the address to start counting from
19 *
20 * This operation is atomic and provides release barrier semantics.
21 */
22#define clear_bit_unlock(nr, addr) \
23do { \
4e857c58 24 smp_mb__before_atomic(); \
26333576
NP
25 clear_bit(nr, addr); \
26} while (0)
27
28/**
29 * __clear_bit_unlock - Clear a bit in memory, for unlock
30 * @nr: the bit to set
31 * @addr: the address to start counting from
32 *
f75d4864
PZ
33 * A weaker form of clear_bit_unlock() as used by __bit_lock_unlock(). If all
34 * the bits in the word are protected by this lock some archs can use weaker
35 * ops to safely unlock.
36 *
37 * See for example x86's implementation.
26333576
NP
38 */
39#define __clear_bit_unlock(nr, addr) \
40do { \
f75d4864
PZ
41 smp_mb__before_atomic(); \
42 clear_bit(nr, addr); \
26333576
NP
43} while (0)
44
45#endif /* _ASM_GENERIC_BITOPS_LOCK_H_ */
46