Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / csky / include / asm / bitops.h
blob43b9838bff63d153a1942c1d292f8bc81af70599
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #ifndef __ASM_CSKY_BITOPS_H
5 #define __ASM_CSKY_BITOPS_H
7 #include <linux/compiler.h>
8 #include <asm/barrier.h>
11 * asm-generic/bitops/ffs.h
13 static inline int ffs(int x)
15 if (!x)
16 return 0;
18 asm volatile (
19 "brev %0\n"
20 "ff1 %0\n"
21 "addi %0, 1\n"
22 : "=&r"(x)
23 : "0"(x));
24 return x;
28 * asm-generic/bitops/__ffs.h
30 static __always_inline unsigned long __ffs(unsigned long x)
32 asm volatile (
33 "brev %0\n"
34 "ff1 %0\n"
35 : "=&r"(x)
36 : "0"(x));
37 return x;
41 * asm-generic/bitops/fls.h
43 static __always_inline int fls(unsigned int x)
45 asm volatile(
46 "ff1 %0\n"
47 : "=&r"(x)
48 : "0"(x));
50 return (32 - x);
54 * asm-generic/bitops/__fls.h
56 static __always_inline unsigned long __fls(unsigned long x)
58 return fls(x) - 1;
61 #include <asm-generic/bitops/ffz.h>
62 #include <asm-generic/bitops/fls64.h>
63 #include <asm-generic/bitops/find.h>
65 #ifndef _LINUX_BITOPS_H
66 #error only <linux/bitops.h> can be included directly
67 #endif
69 #include <asm-generic/bitops/sched.h>
70 #include <asm-generic/bitops/hweight.h>
71 #include <asm-generic/bitops/lock.h>
72 #include <asm-generic/bitops/atomic.h>
75 * bug fix, why only could use atomic!!!!
77 #include <asm-generic/bitops/non-atomic.h>
78 #define __clear_bit(nr, vaddr) clear_bit(nr, vaddr)
80 #include <asm-generic/bitops/le.h>
81 #include <asm-generic/bitops/ext2-atomic.h>
82 #endif /* __ASM_CSKY_BITOPS_H */