Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Akinobu Mita and committed by
Linus Torvalds
a56560b3 c4945b9e

+59 -28
+2 -2
arch/powerpc/include/asm/bitops.h
··· 305 305 306 306 #define find_first_zero_bit_le(addr, size) \ 307 307 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, 309 309 unsigned long size, unsigned long offset); 310 310 311 - unsigned long find_next_bit_le(const unsigned long *addr, 311 + unsigned long find_next_bit_le(const void *addr, 312 312 unsigned long size, unsigned long offset); 313 313 /* Bitmap functions for the ext2 filesystem */ 314 314
+51 -22
include/asm-generic/bitops/le.h
··· 8 8 9 9 #define BITOP_LE_SWIZZLE 0 10 10 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 + } 17 28 18 29 #elif defined(__BIG_ENDIAN) 19 30 20 31 #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) 21 32 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, 23 34 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, 25 36 unsigned long size, unsigned long offset); 26 37 27 38 #define find_first_zero_bit_le(addr, size) \ ··· 42 31 #error "Please fix <asm/byteorder.h>" 43 32 #endif 44 33 45 - #define test_bit_le(nr, addr) \ 46 - test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 47 - #define __set_bit_le(nr, addr) \ 48 - __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 49 - #define __clear_bit_le(nr, addr) \ 50 - __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 34 + static inline int test_bit_le(int nr, const void *addr) 35 + { 36 + return test_bit(nr ^ BITOP_LE_SWIZZLE, addr); 37 + } 51 38 52 - #define test_and_set_bit_le(nr, addr) \ 53 - test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 54 - #define test_and_clear_bit_le(nr, addr) \ 55 - test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 39 + static inline void __set_bit_le(int nr, void *addr) 40 + { 41 + __set_bit(nr ^ BITOP_LE_SWIZZLE, addr); 42 + } 56 43 57 - #define __test_and_set_bit_le(nr, addr) \ 58 - __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 59 - #define __test_and_clear_bit_le(nr, addr) \ 60 - __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 44 + static inline void __clear_bit_le(int nr, void *addr) 45 + { 46 + __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); 47 + } 48 + 49 + static inline int test_and_set_bit_le(int nr, void *addr) 50 + { 51 + return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); 52 + } 53 + 54 + static inline int test_and_clear_bit_le(int nr, void *addr) 55 + { 56 + return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); 57 + } 58 + 59 + static inline int __test_and_set_bit_le(int nr, void *addr) 60 + { 61 + return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); 62 + } 63 + 64 + static inline int __test_and_clear_bit_le(int nr, void *addr) 65 + { 66 + return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); 67 + } 61 68 62 69 #endif /* _ASM_GENERIC_BITOPS_LE_H_ */
+6 -4
lib/find_next_bit.c
··· 185 185 #endif 186 186 } 187 187 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 189 189 long size, unsigned long offset) 190 190 { 191 - const unsigned long *p = addr + BITOP_WORD(offset); 191 + const unsigned long *p = addr; 192 192 unsigned long result = offset & ~(BITS_PER_LONG - 1); 193 193 unsigned long tmp; 194 194 195 195 if (offset >= size) 196 196 return size; 197 + p += BITOP_WORD(offset); 197 198 size -= result; 198 199 offset &= (BITS_PER_LONG - 1UL); 199 200 if (offset) { ··· 229 228 } 230 229 EXPORT_SYMBOL(find_next_zero_bit_le); 231 230 232 - unsigned long find_next_bit_le(const unsigned long *addr, unsigned 231 + unsigned long find_next_bit_le(const void *addr, unsigned 233 232 long size, unsigned long offset) 234 233 { 235 - const unsigned long *p = addr + BITOP_WORD(offset); 234 + const unsigned long *p = addr; 236 235 unsigned long result = offset & ~(BITS_PER_LONG - 1); 237 236 unsigned long tmp; 238 237 239 238 if (offset >= size) 240 239 return size; 240 + p += BITOP_WORD(offset); 241 241 size -= result; 242 242 offset &= (BITS_PER_LONG - 1UL); 243 243 if (offset) {