Skip to content

Commit a56560b

Browse files
mitatorvalds
authored andcommitted
asm-generic: change little-endian bitops to take any pointer types
This makes the little-endian bitops take any pointer types by changing the prototypes and adding casts in the preprocessor macros. That would seem to at least make all the filesystem code happier, and they can continue to do just something like #define ext2_set_bit __test_and_set_bit_le (or whatever the exact sequence ends up being). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Mikael Starvik <starvik@axis.com> Cc: David Howells <dhowells@redhat.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Matthew Wilcox <willy@debian.org> Cc: Grant Grundler <grundler@parisc-linux.org> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp> Cc: Hirokazu Takata <takata@linux-m32r.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Chris Zankel <chris@zankel.net> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c4945b9 commit a56560b

3 files changed

Lines changed: 61 additions & 30 deletions

File tree

arch/powerpc/include/asm/bitops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ static __inline__ int test_le_bit(unsigned long nr,
305305

306306
#define find_first_zero_bit_le(addr, size) \
307307
find_next_zero_bit_le((addr), (size), 0)
308-
unsigned long find_next_zero_bit_le(const unsigned long *addr,
308+
unsigned long find_next_zero_bit_le(const void *addr,
309309
unsigned long size, unsigned long offset);
310310

311-
unsigned long find_next_bit_le(const unsigned long *addr,
311+
unsigned long find_next_bit_le(const void *addr,
312312
unsigned long size, unsigned long offset);
313313
/* Bitmap functions for the ext2 filesystem */
314314

include/asm-generic/bitops/le.h

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,31 @@
88

99
#define BITOP_LE_SWIZZLE 0
1010

11-
#define find_next_zero_bit_le(addr, size, offset) \
12-
find_next_zero_bit(addr, size, offset)
13-
#define find_next_bit_le(addr, size, offset) \
14-
find_next_bit(addr, size, offset)
15-
#define find_first_zero_bit_le(addr, size) \
16-
find_first_zero_bit(addr, size)
11+
static inline unsigned long find_next_zero_bit_le(const void *addr,
12+
unsigned long size, unsigned long offset)
13+
{
14+
return find_next_zero_bit(addr, size, offset);
15+
}
16+
17+
static inline unsigned long find_next_bit_le(const void *addr,
18+
unsigned long size, unsigned long offset)
19+
{
20+
return find_next_bit(addr, size, offset);
21+
}
22+
23+
static inline unsigned long find_first_zero_bit_le(const void *addr,
24+
unsigned long size)
25+
{
26+
return find_first_zero_bit(addr, size);
27+
}
1728

1829
#elif defined(__BIG_ENDIAN)
1930

2031
#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
2132

22-
extern unsigned long find_next_zero_bit_le(const unsigned long *addr,
33+
extern unsigned long find_next_zero_bit_le(const void *addr,
2334
unsigned long size, unsigned long offset);
24-
extern unsigned long find_next_bit_le(const unsigned long *addr,
35+
extern unsigned long find_next_bit_le(const void *addr,
2536
unsigned long size, unsigned long offset);
2637

2738
#define find_first_zero_bit_le(addr, size) \
@@ -31,21 +42,39 @@ extern unsigned long find_next_bit_le(const unsigned long *addr,
3142
#error "Please fix <asm/byteorder.h>"
3243
#endif
3344

34-
#define test_bit_le(nr, addr) \
35-
test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
36-
#define __set_bit_le(nr, addr) \
37-
__set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
38-
#define __clear_bit_le(nr, addr) \
39-
__clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
40-
41-
#define test_and_set_bit_le(nr, addr) \
42-
test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
43-
#define test_and_clear_bit_le(nr, addr) \
44-
test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
45-
46-
#define __test_and_set_bit_le(nr, addr) \
47-
__test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
48-
#define __test_and_clear_bit_le(nr, addr) \
49-
__test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
45+
static inline int test_bit_le(int nr, const void *addr)
46+
{
47+
return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
48+
}
49+
50+
static inline void __set_bit_le(int nr, void *addr)
51+
{
52+
__set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
53+
}
54+
55+
static inline void __clear_bit_le(int nr, void *addr)
56+
{
57+
__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
58+
}
59+
60+
static inline int test_and_set_bit_le(int nr, void *addr)
61+
{
62+
return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
63+
}
64+
65+
static inline int test_and_clear_bit_le(int nr, void *addr)
66+
{
67+
return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
68+
}
69+
70+
static inline int __test_and_set_bit_le(int nr, void *addr)
71+
{
72+
return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
73+
}
74+
75+
static inline int __test_and_clear_bit_le(int nr, void *addr)
76+
{
77+
return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
78+
}
5079

5180
#endif /* _ASM_GENERIC_BITOPS_LE_H_ */

lib/find_next_bit.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,16 @@ static inline unsigned long ext2_swab(const unsigned long y)
185185
#endif
186186
}
187187

188-
unsigned long find_next_zero_bit_le(const unsigned long *addr, unsigned
188+
unsigned long find_next_zero_bit_le(const void *addr, unsigned
189189
long size, unsigned long offset)
190190
{
191-
const unsigned long *p = addr + BITOP_WORD(offset);
191+
const unsigned long *p = addr;
192192
unsigned long result = offset & ~(BITS_PER_LONG - 1);
193193
unsigned long tmp;
194194

195195
if (offset >= size)
196196
return size;
197+
p += BITOP_WORD(offset);
197198
size -= result;
198199
offset &= (BITS_PER_LONG - 1UL);
199200
if (offset) {
@@ -228,15 +229,16 @@ unsigned long find_next_zero_bit_le(const unsigned long *addr, unsigned
228229
}
229230
EXPORT_SYMBOL(find_next_zero_bit_le);
230231

231-
unsigned long find_next_bit_le(const unsigned long *addr, unsigned
232+
unsigned long find_next_bit_le(const void *addr, unsigned
232233
long size, unsigned long offset)
233234
{
234-
const unsigned long *p = addr + BITOP_WORD(offset);
235+
const unsigned long *p = addr;
235236
unsigned long result = offset & ~(BITS_PER_LONG - 1);
236237
unsigned long tmp;
237238

238239
if (offset >= size)
239240
return size;
241+
p += BITOP_WORD(offset);
240242
size -= result;
241243
offset &= (BITS_PER_LONG - 1UL);
242244
if (offset) {

0 commit comments

Comments
 (0)