1
2
3
4
5
6
7#ifndef _BLACKFIN_BITOPS_H
8#define _BLACKFIN_BITOPS_H
9
10#include <linux/compiler.h>
11
12#include <asm-generic/bitops/__ffs.h>
13#include <asm-generic/bitops/ffz.h>
14#include <asm-generic/bitops/fls.h>
15#include <asm-generic/bitops/__fls.h>
16#include <asm-generic/bitops/fls64.h>
17#include <asm-generic/bitops/find.h>
18
19#ifndef _LINUX_BITOPS_H
20#error only <linux/bitops.h> can be included directly
21#endif
22
23#include <asm-generic/bitops/sched.h>
24#include <asm-generic/bitops/ffs.h>
25#include <asm-generic/bitops/const_hweight.h>
26#include <asm-generic/bitops/lock.h>
27
28#include <asm-generic/bitops/ext2-atomic.h>
29
30#include <asm/barrier.h>
31
32#ifndef CONFIG_SMP
33#include <linux/irqflags.h>
34
35
36
37#include <asm-generic/bitops/atomic.h>
38#include <asm-generic/bitops/non-atomic.h>
39#else
40
41#include <asm/byteorder.h>
42#include <linux/linkage.h>
43
44asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
45
46asmlinkage int __raw_bit_clear_asm(volatile unsigned long *addr, int nr);
47
48asmlinkage int __raw_bit_toggle_asm(volatile unsigned long *addr, int nr);
49
50asmlinkage int __raw_bit_test_set_asm(volatile unsigned long *addr, int nr);
51
52asmlinkage int __raw_bit_test_clear_asm(volatile unsigned long *addr, int nr);
53
54asmlinkage int __raw_bit_test_toggle_asm(volatile unsigned long *addr, int nr);
55
56asmlinkage int __raw_bit_test_asm(const volatile unsigned long *addr, int nr);
57
58static inline void set_bit(int nr, volatile unsigned long *addr)
59{
60 volatile unsigned long *a = addr + (nr >> 5);
61 __raw_bit_set_asm(a, nr & 0x1f);
62}
63
64static inline void clear_bit(int nr, volatile unsigned long *addr)
65{
66 volatile unsigned long *a = addr + (nr >> 5);
67 __raw_bit_clear_asm(a, nr & 0x1f);
68}
69
70static inline void change_bit(int nr, volatile unsigned long *addr)
71{
72 volatile unsigned long *a = addr + (nr >> 5);
73 __raw_bit_toggle_asm(a, nr & 0x1f);
74}
75
76static inline int test_bit(int nr, const volatile unsigned long *addr)
77{
78 volatile const unsigned long *a = addr + (nr >> 5);
79 return __raw_bit_test_asm(a, nr & 0x1f) != 0;
80}
81
82static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
83{
84 volatile unsigned long *a = addr + (nr >> 5);
85 return __raw_bit_test_set_asm(a, nr & 0x1f);
86}
87
88static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
89{
90 volatile unsigned long *a = addr + (nr >> 5);
91 return __raw_bit_test_clear_asm(a, nr & 0x1f);
92}
93
94static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
95{
96 volatile unsigned long *a = addr + (nr >> 5);
97 return __raw_bit_test_toggle_asm(a, nr & 0x1f);
98}
99
100#define test_bit __skip_test_bit
101#include <asm-generic/bitops/non-atomic.h>
102#undef test_bit
103
104#endif
105
106
107#include <asm-generic/bitops/le.h>
108
109
110
111
112
113
114static inline unsigned int __arch_hweight32(unsigned int w)
115{
116 unsigned int res;
117
118 __asm__ ("%0.l = ONES %1;"
119 "%0 = %0.l (Z);"
120 : "=d" (res) : "d" (w));
121 return res;
122}
123
124static inline unsigned int __arch_hweight64(__u64 w)
125{
126 return __arch_hweight32((unsigned int)(w >> 32)) +
127 __arch_hweight32((unsigned int)w);
128}
129
130static inline unsigned int __arch_hweight16(unsigned int w)
131{
132 return __arch_hweight32(w & 0xffff);
133}
134
135static inline unsigned int __arch_hweight8(unsigned int w)
136{
137 return __arch_hweight32(w & 0xff);
138}
139
140#endif
141