1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_BITOPS_H
3 #define __ASM_SH_BITOPS_H
7 #ifndef _LINUX_BITOPS_H
8 #error only <linux/bitops.h> can be included directly
12 #include <asm/byteorder.h>
13 #include <asm/barrier.h>
16 #include <asm/bitops-grb.h>
17 #elif defined(CONFIG_CPU_SH2A)
18 #include <asm-generic/bitops/atomic.h>
19 #include <asm/bitops-op32.h>
20 #elif defined(CONFIG_CPU_SH4A)
21 #include <asm/bitops-llsc.h>
22 #elif defined(CONFIG_CPU_J2) && defined(CONFIG_SMP)
23 #include <asm/bitops-cas.h>
25 #include <asm-generic/bitops/atomic.h>
26 #include <asm-generic/bitops/non-atomic.h>
29 #ifdef CONFIG_SUPERH32
30 static inline unsigned long ffz(unsigned long word
)
38 : "=r" (result
), "=r" (word
)
39 : "0" (~0L), "1" (word
)
45 * __ffs - find first bit in word.
46 * @word: The word to search
48 * Undefined if no bit exists, so code should check against 0 first.
50 static inline unsigned long __ffs(unsigned long word
)
58 : "=r" (result
), "=r" (word
)
59 : "0" (~0L), "1" (word
)
64 static inline unsigned long ffz(unsigned long word
)
66 unsigned long result
, __d2
, __d3
;
68 __asm__("gettr tr0, %2\n\t"
71 "beq %3, r63, tr0\n\t"
74 "shlri.l %1, 1, %1\n\t"
80 : "=r" (result
), "=r" (word
), "=r" (__d2
), "=r" (__d3
)
81 : "0" (0L), "1" (word
));
86 #include <asm-generic/bitops/__ffs.h>
89 #include <asm-generic/bitops/find.h>
90 #include <asm-generic/bitops/ffs.h>
91 #include <asm-generic/bitops/hweight.h>
92 #include <asm-generic/bitops/lock.h>
93 #include <asm-generic/bitops/sched.h>
94 #include <asm-generic/bitops/le.h>
95 #include <asm-generic/bitops/ext2-atomic.h>
96 #include <asm-generic/bitops/fls.h>
97 #include <asm-generic/bitops/__fls.h>
98 #include <asm-generic/bitops/fls64.h>
100 #endif /* __KERNEL__ */
102 #endif /* __ASM_SH_BITOPS_H */