/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __ASM_METAG_BITOPS_H #define __ASM_METAG_BITOPS_H #include #include #include #ifdef CONFIG_SMP /* * These functions are the basis of our bit ops. */ static inline void set_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); fence(); *p |= mask; __global_unlock1(flags); } static inline void clear_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); fence(); *p &= ~mask; __global_unlock1(flags); } static inline void change_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); fence(); *p ^= mask; __global_unlock1(flags); } static inline int test_and_set_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long old; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); old = *p; if (!(old & mask)) { fence(); *p = old | mask; } __global_unlock1(flags); return (old & mask) != 0; } static inline int test_and_clear_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long old; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); old = *p; if (old & mask) { fence(); *p = old & ~mask; } __global_unlock1(flags); return (old & mask) != 0; } static inline int test_and_change_bit(unsigned int bit, volatile unsigned long *p) { unsigned long flags; unsigned long old; unsigned long mask = 1UL << (bit & 31); p += bit >> 5; __global_lock1(flags); fence(); old = *p; *p = old ^ mask; __global_unlock1(flags); return (old & mask) != 0; } #else #include #endif /* CONFIG_SMP */ #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* __ASM_METAG_BITOPS_H */