Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef __ASM_SH_BITOPS_H |
3 | #define __ASM_SH_BITOPS_H | |
4 | ||
0624517d JS |
5 | #ifndef _LINUX_BITOPS_H |
6 | #error only <linux/bitops.h> can be included directly | |
7 | #endif | |
8 | ||
1da177e4 LT |
9 | /* For __swab32 */ |
10 | #include <asm/byteorder.h> | |
603228bc | 11 | #include <asm/barrier.h> |
1da177e4 | 12 | |
1efe4ce3 SM |
13 | #ifdef CONFIG_GUSA_RB |
14 | #include <asm/bitops-grb.h> | |
0d5bbe0b PM |
15 | #elif defined(CONFIG_CPU_SH2A) |
16 | #include <asm-generic/bitops/atomic.h> | |
17 | #include <asm/bitops-op32.h> | |
742fd1bc PM |
18 | #elif defined(CONFIG_CPU_SH4A) |
19 | #include <asm/bitops-llsc.h> | |
2b47d54e RF |
20 | #elif defined(CONFIG_CPU_J2) && defined(CONFIG_SMP) |
21 | #include <asm/bitops-cas.h> | |
1efe4ce3 | 22 | #else |
16b529d1 PM |
23 | #include <asm-generic/bitops/atomic.h> |
24 | #include <asm-generic/bitops/non-atomic.h> | |
1efe4ce3 | 25 | #endif |
1da177e4 | 26 | |
e4c2cfee | 27 | static inline unsigned long ffz(unsigned long word) |
1da177e4 LT |
28 | { |
29 | unsigned long result; | |
30 | ||
31 | __asm__("1:\n\t" | |
32 | "shlr %1\n\t" | |
33 | "bt/s 1b\n\t" | |
34 | " add #1, %0" | |
35 | : "=r" (result), "=r" (word) | |
36 | : "0" (~0L), "1" (word) | |
37 | : "t"); | |
38 | return result; | |
39 | } | |
40 | ||
41 | /** | |
42 | * __ffs - find first bit in word. | |
43 | * @word: The word to search | |
44 | * | |
45 | * Undefined if no bit exists, so code should check against 0 first. | |
46 | */ | |
e4c2cfee | 47 | static inline unsigned long __ffs(unsigned long word) |
1da177e4 LT |
48 | { |
49 | unsigned long result; | |
50 | ||
51 | __asm__("1:\n\t" | |
52 | "shlr %1\n\t" | |
53 | "bf/s 1b\n\t" | |
54 | " add #1, %0" | |
55 | : "=r" (result), "=r" (word) | |
56 | : "0" (~0L), "1" (word) | |
57 | : "t"); | |
58 | return result; | |
59 | } | |
60 | ||
e2268c71 AM |
61 | #include <asm-generic/bitops/ffs.h> |
62 | #include <asm-generic/bitops/hweight.h> | |
26333576 | 63 | #include <asm-generic/bitops/lock.h> |
e2268c71 | 64 | #include <asm-generic/bitops/sched.h> |
e2268c71 | 65 | #include <asm-generic/bitops/ext2-atomic.h> |
e2268c71 | 66 | #include <asm-generic/bitops/fls.h> |
56a6b1eb | 67 | #include <asm-generic/bitops/__fls.h> |
e2268c71 | 68 | #include <asm-generic/bitops/fls64.h> |
1da177e4 | 69 | |
bb8bc36e | 70 | #include <asm-generic/bitops/le.h> |
bb8bc36e | 71 | |
1da177e4 | 72 | #endif /* __ASM_SH_BITOPS_H */ |