Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Akinobu Mita | 765f34f | 2006-03-26 01:39:16 -0800 | [diff] [blame] | 2 | #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ |
| 3 | #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ |
| 4 | |
Akinobu Mita | 148817b | 2011-07-26 16:09:04 -0700 | [diff] [blame] | 5 | /* |
| 6 | * Spinlock based version of ext2 atomic bitops |
| 7 | */ |
| 8 | |
Akinobu Mita | 765f34f | 2006-03-26 01:39:16 -0800 | [diff] [blame] | 9 | #define ext2_set_bit_atomic(lock, nr, addr) \ |
| 10 | ({ \ |
| 11 | int ret; \ |
| 12 | spin_lock(lock); \ |
Akinobu Mita | c565300 | 2011-03-23 16:42:04 -0700 | [diff] [blame] | 13 | ret = __test_and_set_bit_le(nr, addr); \ |
Akinobu Mita | 765f34f | 2006-03-26 01:39:16 -0800 | [diff] [blame] | 14 | spin_unlock(lock); \ |
| 15 | ret; \ |
| 16 | }) |
| 17 | |
| 18 | #define ext2_clear_bit_atomic(lock, nr, addr) \ |
| 19 | ({ \ |
| 20 | int ret; \ |
| 21 | spin_lock(lock); \ |
Akinobu Mita | c565300 | 2011-03-23 16:42:04 -0700 | [diff] [blame] | 22 | ret = __test_and_clear_bit_le(nr, addr); \ |
Akinobu Mita | 765f34f | 2006-03-26 01:39:16 -0800 | [diff] [blame] | 23 | spin_unlock(lock); \ |
| 24 | ret; \ |
| 25 | }) |
| 26 | |
| 27 | #endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */ |