Commit 61f2e7b0f474225b4226772830ae4b29a3a21f8d

Authored by Akinobu Mita
Committed by Linus Torvalds
1 parent 3fca5af786

bitops: remove minix bitops from asm/bitops.h

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 <akinobu.mita@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Michal Simek <monstr@monstr.eu>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 27 changed files with 82 additions and 110 deletions Side-by-side Diff

arch/alpha/include/asm/bitops.h
... ... @@ -459,8 +459,6 @@
459 459 #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
460 460 #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
461 461  
462   -#include <asm-generic/bitops/minix.h>
463   -
464 462 #endif /* __KERNEL__ */
465 463  
466 464 #endif /* _ALPHA_BITOPS_H */
arch/arm/include/asm/bitops.h
... ... @@ -345,16 +345,6 @@
345 345 #define ext2_clear_bit_atomic(lock, nr, p) \
346 346 test_and_clear_bit_le(nr, p)
347 347  
348   -/*
349   - * Minix is defined to use little-endian byte ordering.
350   - * These do not need to be atomic.
351   - */
352   -#define minix_set_bit __set_bit_le
353   -#define minix_test_bit test_bit_le
354   -#define minix_test_and_set_bit __test_and_set_bit_le
355   -#define minix_test_and_clear_bit __test_and_clear_bit_le
356   -#define minix_find_first_zero_bit find_first_zero_bit_le
357   -
358 348 #endif /* __KERNEL__ */
359 349  
360 350 #endif /* _ARM_BITOPS_H */
arch/avr32/include/asm/bitops.h
... ... @@ -301,7 +301,6 @@
301 301  
302 302 #include <asm-generic/bitops/le.h>
303 303 #include <asm-generic/bitops/ext2-atomic.h>
304   -#include <asm-generic/bitops/minix-le.h>
305 304  
306 305 #endif /* __ASM_AVR32_BITOPS_H */
arch/blackfin/include/asm/bitops.h
... ... @@ -27,7 +27,6 @@
27 27  
28 28 #include <asm-generic/bitops/le.h>
29 29 #include <asm-generic/bitops/ext2-atomic.h>
30   -#include <asm-generic/bitops/minix.h>
31 30  
32 31 #ifndef CONFIG_SMP
33 32 #include <linux/irqflags.h>
arch/cris/include/asm/bitops.h
... ... @@ -159,7 +159,6 @@
159 159 #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
160 160 #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
161 161  
162   -#include <asm-generic/bitops/minix.h>
163 162 #include <asm-generic/bitops/sched.h>
164 163  
165 164 #endif /* __KERNEL__ */
arch/frv/include/asm/bitops.h
... ... @@ -406,8 +406,6 @@
406 406 #define ext2_set_bit_atomic(lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr))
407 407 #define ext2_clear_bit_atomic(lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr))
408 408  
409   -#include <asm-generic/bitops/minix-le.h>
410   -
411 409 #endif /* __KERNEL__ */
412 410  
413 411 #endif /* _ASM_BITOPS_H */
arch/h8300/include/asm/bitops.h
... ... @@ -202,7 +202,6 @@
202 202 #include <asm-generic/bitops/lock.h>
203 203 #include <asm-generic/bitops/le.h>
204 204 #include <asm-generic/bitops/ext2-atomic.h>
205   -#include <asm-generic/bitops/minix.h>
206 205  
207 206 #endif /* __KERNEL__ */
208 207  
arch/ia64/include/asm/bitops.h
... ... @@ -461,7 +461,6 @@
461 461 #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
462 462 #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
463 463  
464   -#include <asm-generic/bitops/minix.h>
465 464 #include <asm-generic/bitops/sched.h>
466 465  
467 466 #endif /* __KERNEL__ */
arch/m32r/include/asm/bitops.h
... ... @@ -268,7 +268,6 @@
268 268  
269 269 #include <asm-generic/bitops/le.h>
270 270 #include <asm-generic/bitops/ext2-atomic.h>
271   -#include <asm-generic/bitops/minix.h>
272 271  
273 272 #endif /* __KERNEL__ */
274 273  
arch/m68k/include/asm/bitops_mm.h
... ... @@ -325,36 +325,6 @@
325 325 #include <asm-generic/bitops/hweight.h>
326 326 #include <asm-generic/bitops/lock.h>
327 327  
328   -/* Bitmap functions for the minix filesystem */
329   -
330   -static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
331   -{
332   - const unsigned short *p = vaddr, *addr = vaddr;
333   - unsigned short num;
334   -
335   - if (!size)
336   - return 0;
337   -
338   - size = (size >> 4) + ((size & 15) > 0);
339   - while (*p++ == 0xffff) {
340   - if (--size == 0)
341   - return (p - addr) << 4;
342   - }
343   -
344   - num = *--p;
345   - return ((p - addr) << 4) + ffz(num);
346   -}
347   -
348   -#define minix_test_and_set_bit(nr, addr) __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr))
349   -#define minix_set_bit(nr,addr) __set_bit((nr) ^ 16, (unsigned long *)(addr))
350   -#define minix_test_and_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr))
351   -
352   -static inline int minix_test_bit(int nr, const void *vaddr)
353   -{
354   - const unsigned short *p = vaddr;
355   - return (p[nr >> 4] & (1U << (nr & 15))) != 0;
356   -}
357   -
358 328 /* Bitmap functions for the little endian bitmap. */
359 329  
360 330 static inline void __set_bit_le(int nr, void *addr)
arch/m68k/include/asm/bitops_no.h
... ... @@ -336,8 +336,6 @@
336 336 return result + ffz(__swab32(tmp));
337 337 }
338 338  
339   -#include <asm-generic/bitops/minix.h>
340   -
341 339 #endif /* __KERNEL__ */
342 340  
343 341 #include <asm-generic/bitops/fls.h>
arch/mips/include/asm/bitops.h
... ... @@ -678,7 +678,6 @@
678 678  
679 679 #include <asm-generic/bitops/le.h>
680 680 #include <asm-generic/bitops/ext2-atomic.h>
681   -#include <asm-generic/bitops/minix.h>
682 681  
683 682 #endif /* __KERNEL__ */
684 683  
arch/mn10300/include/asm/bitops.h
... ... @@ -234,7 +234,6 @@
234 234 test_and_clear_bit((nr), (addr))
235 235  
236 236 #include <asm-generic/bitops/le.h>
237   -#include <asm-generic/bitops/minix-le.h>
238 237  
239 238 #endif /* __KERNEL__ */
240 239 #endif /* __ASM_BITOPS_H */
arch/parisc/include/asm/bitops.h
... ... @@ -234,7 +234,5 @@
234 234  
235 235 #endif /* __KERNEL__ */
236 236  
237   -#include <asm-generic/bitops/minix-le.h>
238   -
239 237 #endif /* _PARISC_BITOPS_H */
arch/powerpc/include/asm/bitops.h
... ... @@ -332,20 +332,6 @@
332 332 #define ext2_clear_bit_atomic(lock, nr, addr) \
333 333 test_and_clear_bit_le((nr), (unsigned long*)addr)
334 334  
335   -/* Bitmap functions for the minix filesystem. */
336   -
337   -#define minix_test_and_set_bit(nr,addr) \
338   - __test_and_set_bit_le(nr, (unsigned long *)addr)
339   -#define minix_set_bit(nr,addr) \
340   - __set_bit_le(nr, (unsigned long *)addr)
341   -#define minix_test_and_clear_bit(nr,addr) \
342   - __test_and_clear_bit_le(nr, (unsigned long *)addr)
343   -#define minix_test_bit(nr,addr) \
344   - test_bit_le(nr, (unsigned long *)addr)
345   -
346   -#define minix_find_first_zero_bit(addr,size) \
347   - find_first_zero_bit_le((unsigned long *)addr, size)
348   -
349 335 #include <asm-generic/bitops/sched.h>
350 336  
351 337 #endif /* __KERNEL__ */
arch/s390/include/asm/bitops.h
... ... @@ -862,7 +862,6 @@
862 862 #define ext2_clear_bit_atomic(lock, nr, addr) \
863 863 test_and_clear_bit_le(nr, addr)
864 864  
865   -#include <asm-generic/bitops/minix.h>
866 865  
867 866 #endif /* __KERNEL__ */
868 867  
arch/sh/include/asm/bitops.h
... ... @@ -96,7 +96,6 @@
96 96 #include <asm-generic/bitops/sched.h>
97 97 #include <asm-generic/bitops/le.h>
98 98 #include <asm-generic/bitops/ext2-atomic.h>
99   -#include <asm-generic/bitops/minix.h>
100 99 #include <asm-generic/bitops/fls.h>
101 100 #include <asm-generic/bitops/__fls.h>
102 101 #include <asm-generic/bitops/fls64.h>
arch/sparc/include/asm/bitops_32.h
... ... @@ -105,7 +105,6 @@
105 105 #include <asm-generic/bitops/find.h>
106 106 #include <asm-generic/bitops/le.h>
107 107 #include <asm-generic/bitops/ext2-atomic.h>
108   -#include <asm-generic/bitops/minix.h>
109 108  
110 109 #endif /* __KERNEL__ */
111 110  
arch/sparc/include/asm/bitops_64.h
... ... @@ -96,8 +96,6 @@
96 96 #define ext2_clear_bit_atomic(lock,nr,addr) \
97 97 test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr))
98 98  
99   -#include <asm-generic/bitops/minix.h>
100   -
101 99 #endif /* __KERNEL__ */
102 100  
103 101 #endif /* defined(_SPARC64_BITOPS_H) */
arch/tile/include/asm/bitops.h
... ... @@ -123,7 +123,6 @@
123 123 #include <asm-generic/bitops/find.h>
124 124 #include <asm-generic/bitops/sched.h>
125 125 #include <asm-generic/bitops/le.h>
126   -#include <asm-generic/bitops/minix.h>
127 126  
128 127 #endif /* _ASM_TILE_BITOPS_H */
arch/x86/include/asm/bitops.h
... ... @@ -463,8 +463,6 @@
463 463 #define ext2_clear_bit_atomic(lock, nr, addr) \
464 464 test_and_clear_bit((nr), (unsigned long *)(addr))
465 465  
466   -#include <asm-generic/bitops/minix.h>
467   -
468 466 #endif /* __KERNEL__ */
469 467 #endif /* _ASM_X86_BITOPS_H */
arch/xtensa/include/asm/bitops.h
... ... @@ -125,7 +125,6 @@
125 125 #include <asm-generic/bitops/hweight.h>
126 126 #include <asm-generic/bitops/lock.h>
127 127 #include <asm-generic/bitops/sched.h>
128   -#include <asm-generic/bitops/minix.h>
129 128  
130 129 #endif /* __KERNEL__ */
131 130  
... ... @@ -15,4 +15,12 @@
15 15 module will be called minix. Note that the file system of your root
16 16 partition (the one containing the directory /) cannot be compiled as
17 17 a module.
  18 +
  19 +config MINIX_FS_NATIVE_ENDIAN
  20 + def_bool MINIX_FS
  21 + depends on H8300 || M32R || MICROBLAZE || MIPS || S390 || SUPERH || SPARC || XTENSA || (M68K && !MMU)
  22 +
  23 +config MINIX_FS_BIG_ENDIAN_16BIT_INDEXED
  24 + def_bool MINIX_FS
  25 + depends on M68K && MMU
... ... @@ -88,5 +88,79 @@
88 88 return list_entry(inode, struct minix_inode_info, vfs_inode);
89 89 }
90 90  
  91 +#if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \
  92 + defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)
  93 +
  94 +#error Minix file system byte order broken
  95 +
  96 +#elif defined(CONFIG_MINIX_FS_NATIVE_ENDIAN)
  97 +
  98 +/*
  99 + * big-endian 32 or 64 bit indexed bitmaps on big-endian system or
  100 + * little-endian bitmaps on little-endian system
  101 + */
  102 +
  103 +#define minix_test_and_set_bit(nr, addr) \
  104 + __test_and_set_bit((nr), (unsigned long *)(addr))
  105 +#define minix_set_bit(nr, addr) \
  106 + __set_bit((nr), (unsigned long *)(addr))
  107 +#define minix_test_and_clear_bit(nr, addr) \
  108 + __test_and_clear_bit((nr), (unsigned long *)(addr))
  109 +#define minix_test_bit(nr, addr) \
  110 + test_bit((nr), (unsigned long *)(addr))
  111 +#define minix_find_first_zero_bit(addr, size) \
  112 + find_first_zero_bit((unsigned long *)(addr), (size))
  113 +
  114 +#elif defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED)
  115 +
  116 +/*
  117 + * big-endian 16bit indexed bitmaps
  118 + */
  119 +
  120 +static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
  121 +{
  122 + const unsigned short *p = vaddr, *addr = vaddr;
  123 + unsigned short num;
  124 +
  125 + if (!size)
  126 + return 0;
  127 +
  128 + size = (size >> 4) + ((size & 15) > 0);
  129 + while (*p++ == 0xffff) {
  130 + if (--size == 0)
  131 + return (p - addr) << 4;
  132 + }
  133 +
  134 + num = *--p;
  135 + return ((p - addr) << 4) + ffz(num);
  136 +}
  137 +
  138 +#define minix_test_and_set_bit(nr, addr) \
  139 + __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr))
  140 +#define minix_set_bit(nr, addr) \
  141 + __set_bit((nr) ^ 16, (unsigned long *)(addr))
  142 +#define minix_test_and_clear_bit(nr, addr) \
  143 + __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr))
  144 +
  145 +static inline int minix_test_bit(int nr, const void *vaddr)
  146 +{
  147 + const unsigned short *p = vaddr;
  148 + return (p[nr >> 4] & (1U << (nr & 15))) != 0;
  149 +}
  150 +
  151 +#else
  152 +
  153 +/*
  154 + * little-endian bitmaps
  155 + */
  156 +
  157 +#define minix_test_and_set_bit __test_and_set_bit_le
  158 +#define minix_set_bit __set_bit_le
  159 +#define minix_test_and_clear_bit __test_and_clear_bit_le
  160 +#define minix_test_bit test_bit_le
  161 +#define minix_find_first_zero_bit find_first_zero_bit_le
  162 +
  163 +#endif
  164 +
91 165 #endif /* FS_MINIX_H */
include/asm-generic/bitops.h
... ... @@ -40,7 +40,6 @@
40 40 #include <asm-generic/bitops/non-atomic.h>
41 41 #include <asm-generic/bitops/le.h>
42 42 #include <asm-generic/bitops/ext2-atomic.h>
43   -#include <asm-generic/bitops/minix.h>
44 43  
45 44 #endif /* __ASM_GENERIC_BITOPS_H */
include/asm-generic/bitops/minix-le.h
1   -#ifndef _ASM_GENERIC_BITOPS_MINIX_LE_H_
2   -#define _ASM_GENERIC_BITOPS_MINIX_LE_H_
3   -
4   -#define minix_test_and_set_bit(nr,addr) \
5   - __test_and_set_bit_le((nr), (unsigned long *)(addr))
6   -#define minix_set_bit(nr,addr) \
7   - __set_bit_le((nr), (unsigned long *)(addr))
8   -#define minix_test_and_clear_bit(nr,addr) \
9   - __test_and_clear_bit_le((nr), (unsigned long *)(addr))
10   -#define minix_test_bit(nr,addr) \
11   - test_bit_le((nr), (unsigned long *)(addr))
12   -#define minix_find_first_zero_bit(addr,size) \
13   - find_first_zero_bit_le((unsigned long *)(addr), (size))
14   -
15   -#endif /* _ASM_GENERIC_BITOPS_MINIX_LE_H_ */
include/asm-generic/bitops/minix.h
1   -#ifndef _ASM_GENERIC_BITOPS_MINIX_H_
2   -#define _ASM_GENERIC_BITOPS_MINIX_H_
3   -
4   -#define minix_test_and_set_bit(nr,addr) \
5   - __test_and_set_bit((nr),(unsigned long *)(addr))
6   -#define minix_set_bit(nr,addr) \
7   - __set_bit((nr),(unsigned long *)(addr))
8   -#define minix_test_and_clear_bit(nr,addr) \
9   - __test_and_clear_bit((nr),(unsigned long *)(addr))
10   -#define minix_test_bit(nr,addr) \
11   - test_bit((nr),(unsigned long *)(addr))
12   -#define minix_find_first_zero_bit(addr,size) \
13   - find_first_zero_bit((unsigned long *)(addr),(size))
14   -
15   -#endif /* _ASM_GENERIC_BITOPS_MINIX_H_ */