Skip to content

Commit

Permalink
bitops: remove minix bitops from asm/bitops.h
Browse files Browse the repository at this point in the history
minix bit operations are only used by minix filesystem and useless by
other modules.  Because byte order of inode and block bitmaps is different
on each architecture like below:

m68k:
	big-endian 16bit indexed bitmaps

h8300, microblaze, s390, sparc, m68knommu:
	big-endian 32 or 64bit indexed bitmaps

m32r, mips, sh, xtensa:
	big-endian 32 or 64bit indexed bitmaps for big-endian mode
	little-endian bitmaps for little-endian mode

Others:
	little-endian bitmaps

In order to move minix bit operations from asm/bitops.h to architecture
independent code in minix filesystem, this provides two config options.

CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED is only selected by m68k.
CONFIG_MINIX_FS_NATIVE_ENDIAN is selected by the architectures which use
native byte order bitmaps (h8300, microblaze, s390, sparc, m68knommu,
m32r, mips, sh, xtensa).  The architectures which always use little-endian
bitmaps do not select these options.

Finally, we can remove minix bit operations from asm/bitops.h for all
architectures.

Signed-off-by: Akinobu Mita <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Acked-by: Greg Ungerer <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Roman Zippel <[email protected]>
Cc: Andreas Schwab <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Acked-by: Paul Mundt <[email protected]>
Cc: Chris Zankel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Mar 24, 2011
1 parent 3fca5af commit 61f2e7b
Show file tree
Hide file tree
Showing 27 changed files with 82 additions and 110 deletions.
2 changes: 0 additions & 2 deletions arch/alpha/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ sched_find_first_bit(const unsigned long b[2])
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)

#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

#endif /* _ALPHA_BITOPS_H */
10 changes: 0 additions & 10 deletions arch/arm/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,6 @@ static inline int find_next_bit_le(const void *p, int size, int offset)
#define ext2_clear_bit_atomic(lock, nr, p) \
test_and_clear_bit_le(nr, p)

/*
* Minix is defined to use little-endian byte ordering.
* These do not need to be atomic.
*/
#define minix_set_bit __set_bit_le
#define minix_test_bit test_bit_le
#define minix_test_and_set_bit __test_and_set_bit_le
#define minix_test_and_clear_bit __test_and_clear_bit_le
#define minix_find_first_zero_bit find_first_zero_bit_le

#endif /* __KERNEL__ */

#endif /* _ARM_BITOPS_H */
1 change: 0 additions & 1 deletion arch/avr32/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,5 @@ static inline int ffs(unsigned long word)

#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix-le.h>

#endif /* __ASM_AVR32_BITOPS_H */
1 change: 0 additions & 1 deletion arch/blackfin/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#ifndef CONFIG_SMP
#include <linux/irqflags.h>
Expand Down
1 change: 0 additions & 1 deletion arch/cris/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)

#include <asm-generic/bitops/minix.h>
#include <asm-generic/bitops/sched.h>

#endif /* __KERNEL__ */
Expand Down
2 changes: 0 additions & 2 deletions arch/frv/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ int __ilog2_u64(u64 n)
#define ext2_set_bit_atomic(lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr))
#define ext2_clear_bit_atomic(lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr))

#include <asm-generic/bitops/minix-le.h>

#endif /* __KERNEL__ */

#endif /* _ASM_BITOPS_H */
1 change: 0 additions & 1 deletion arch/h8300/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ static __inline__ unsigned long __ffs(unsigned long word)
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
1 change: 0 additions & 1 deletion arch/ia64/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)

#include <asm-generic/bitops/minix.h>
#include <asm-generic/bitops/sched.h>

#endif /* __KERNEL__ */
Expand Down
1 change: 0 additions & 1 deletion arch/m32r/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr)

#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
30 changes: 0 additions & 30 deletions arch/m68k/include/asm/bitops_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,36 +325,6 @@ static inline int __fls(int x)
#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/lock.h>

/* Bitmap functions for the minix filesystem */

static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
{
const unsigned short *p = vaddr, *addr = vaddr;
unsigned short num;

if (!size)
return 0;

size = (size >> 4) + ((size & 15) > 0);
while (*p++ == 0xffff) {
if (--size == 0)
return (p - addr) << 4;
}

num = *--p;
return ((p - addr) << 4) + ffz(num);
}

#define minix_test_and_set_bit(nr, addr) __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr))
#define minix_set_bit(nr,addr) __set_bit((nr) ^ 16, (unsigned long *)(addr))
#define minix_test_and_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr))

static inline int minix_test_bit(int nr, const void *vaddr)
{
const unsigned short *p = vaddr;
return (p[nr >> 4] & (1U << (nr & 15))) != 0;
}

/* Bitmap functions for the little endian bitmap. */

static inline void __set_bit_le(int nr, void *addr)
Expand Down
2 changes: 0 additions & 2 deletions arch/m68k/include/asm/bitops_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ static inline unsigned long find_next_zero_bit_le(void *addr, unsigned long size
return result + ffz(__swab32(tmp));
}

#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

#include <asm-generic/bitops/fls.h>
Expand Down
1 change: 0 additions & 1 deletion arch/mips/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ static inline int ffs(int word)

#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
1 change: 0 additions & 1 deletion arch/mn10300/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ int ffs(int x)
test_and_clear_bit((nr), (addr))

#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/minix-le.h>

#endif /* __KERNEL__ */
#endif /* __ASM_BITOPS_H */
2 changes: 0 additions & 2 deletions arch/parisc/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,4 @@ static __inline__ int fls(int x)

#endif /* __KERNEL__ */

#include <asm-generic/bitops/minix-le.h>

#endif /* _PARISC_BITOPS_H */
14 changes: 0 additions & 14 deletions arch/powerpc/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,6 @@ unsigned long find_next_bit_le(const void *addr,
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit_le((nr), (unsigned long*)addr)

/* Bitmap functions for the minix filesystem. */

#define minix_test_and_set_bit(nr,addr) \
__test_and_set_bit_le(nr, (unsigned long *)addr)
#define minix_set_bit(nr,addr) \
__set_bit_le(nr, (unsigned long *)addr)
#define minix_test_and_clear_bit(nr,addr) \
__test_and_clear_bit_le(nr, (unsigned long *)addr)
#define minix_test_bit(nr,addr) \
test_bit_le(nr, (unsigned long *)addr)

#define minix_find_first_zero_bit(addr,size) \
find_first_zero_bit_le((unsigned long *)addr, size)

#include <asm-generic/bitops/sched.h>

#endif /* __KERNEL__ */
Expand Down
1 change: 0 additions & 1 deletion arch/s390/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,6 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size,
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit_le(nr, addr)

#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
1 change: 0 additions & 1 deletion arch/sh/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ static inline unsigned long ffz(unsigned long word)
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
Expand Down
1 change: 0 additions & 1 deletion arch/sparc/include/asm/bitops_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
2 changes: 0 additions & 2 deletions arch/sparc/include/asm/bitops_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ static inline unsigned int __arch_hweight8(unsigned int w)
#define ext2_clear_bit_atomic(lock,nr,addr) \
test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr))

#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

#endif /* defined(_SPARC64_BITOPS_H) */
1 change: 0 additions & 1 deletion arch/tile/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,5 @@ static inline unsigned long __arch_hweight64(__u64 w)
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/minix.h>

#endif /* _ASM_TILE_BITOPS_H */
2 changes: 0 additions & 2 deletions arch/x86/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,5 @@ static inline int fls(int x)
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit((nr), (unsigned long *)(addr))

#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */
#endif /* _ASM_X86_BITOPS_H */
1 change: 0 additions & 1 deletion arch/xtensa/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ static inline unsigned long __fls(unsigned long word)
#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down
8 changes: 8 additions & 0 deletions fs/minix/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ config MINIX_FS
module will be called minix. Note that the file system of your root
partition (the one containing the directory /) cannot be compiled as
a module.

config MINIX_FS_NATIVE_ENDIAN
def_bool MINIX_FS
depends on H8300 || M32R || MICROBLAZE || MIPS || S390 || SUPERH || SPARC || XTENSA || (M68K && !MMU)

config MINIX_FS_BIG_ENDIAN_16BIT_INDEXED
def_bool MINIX_FS
depends on M68K && MMU
74 changes: 74 additions & 0 deletions fs/minix/minix.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,78 @@ static inline struct minix_inode_info *minix_i(struct inode *inode)
return list_entry(inode, struct minix_inode_info, vfs_inode);
}

#if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \
defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)

#error Minix file system byte order broken

#elif defined(CONFIG_MINIX_FS_NATIVE_ENDIAN)

/*
* big-endian 32 or 64 bit indexed bitmaps on big-endian system or
* little-endian bitmaps on little-endian system
*/

#define minix_test_and_set_bit(nr, addr) \
__test_and_set_bit((nr), (unsigned long *)(addr))
#define minix_set_bit(nr, addr) \
__set_bit((nr), (unsigned long *)(addr))
#define minix_test_and_clear_bit(nr, addr) \
__test_and_clear_bit((nr), (unsigned long *)(addr))
#define minix_test_bit(nr, addr) \
test_bit((nr), (unsigned long *)(addr))
#define minix_find_first_zero_bit(addr, size) \
find_first_zero_bit((unsigned long *)(addr), (size))

#elif defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)

/*
* big-endian 16bit indexed bitmaps
*/

static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
{
const unsigned short *p = vaddr, *addr = vaddr;
unsigned short num;

if (!size)
return 0;

size = (size >> 4) + ((size & 15) > 0);
while (*p++ == 0xffff) {
if (--size == 0)
return (p - addr) << 4;
}

num = *--p;
return ((p - addr) << 4) + ffz(num);
}

#define minix_test_and_set_bit(nr, addr) \
__test_and_set_bit((nr) ^ 16, (unsigned long *)(addr))
#define minix_set_bit(nr, addr) \
__set_bit((nr) ^ 16, (unsigned long *)(addr))
#define minix_test_and_clear_bit(nr, addr) \
__test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr))

static inline int minix_test_bit(int nr, const void *vaddr)
{
const unsigned short *p = vaddr;
return (p[nr >> 4] & (1U << (nr & 15))) != 0;
}

#else

/*
* little-endian bitmaps
*/

#define minix_test_and_set_bit __test_and_set_bit_le
#define minix_set_bit __set_bit_le
#define minix_test_and_clear_bit __test_and_clear_bit_le
#define minix_test_bit test_bit_le
#define minix_find_first_zero_bit find_first_zero_bit_le

#endif

#endif /* FS_MINIX_H */
1 change: 0 additions & 1 deletion include/asm-generic/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@
#include <asm-generic/bitops/non-atomic.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __ASM_GENERIC_BITOPS_H */
15 changes: 0 additions & 15 deletions include/asm-generic/bitops/minix-le.h

This file was deleted.

15 changes: 0 additions & 15 deletions include/asm-generic/bitops/minix.h

This file was deleted.

0 comments on commit 61f2e7b

Please sign in to comment.