^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Spinlock based version of ext2 atomic bitops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define ext2_set_bit_atomic(lock, nr, addr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) int ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) spin_lock(lock); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ret = __test_and_set_bit_le(nr, addr); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) spin_unlock(lock); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define ext2_clear_bit_atomic(lock, nr, addr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) spin_lock(lock); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ret = __test_and_clear_bit_le(nr, addr); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) spin_unlock(lock); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ret; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */