diff options
author | Jon Mason <jdmason@us.ibm.com> | 2006-05-19 16:35:32 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-05-24 02:08:58 -0400 |
commit | 0a9cb46a73abd6c45e7c986bec984eed60c417b6 (patch) | |
tree | e713d9a0d03de947f3727e6fead942024f4c0767 /arch/powerpc | |
parent | 7499bf1a4cabde789e7694b33d01a1913ae1dddf (diff) |
[PATCH] remove powerpc bitops in favor of existing generic bitops
There already exists a big endian safe bitops implementation in
lib/find_next_bit.c. The code in it is 90%+ common with the powerpc
specific version, so the powerpc version is redundant. This patch
makes the necessary changes to use the generic bitops in powerpc, and
removes the powerpc specific version.
Signed-off-by: Jon Mason <jdmason@us.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/Kconfig | 4 | ||||
-rw-r--r-- | arch/powerpc/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/lib/bitops.c | 150 |
3 files changed, 4 insertions, 151 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 6729c98b66f9..75ba0ec49e54 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -45,6 +45,10 @@ config GENERIC_CALIBRATE_DELAY | |||
45 | bool | 45 | bool |
46 | default y | 46 | default y |
47 | 47 | ||
48 | config GENERIC_FIND_NEXT_BIT | ||
49 | bool | ||
50 | default y | ||
51 | |||
48 | config PPC | 52 | config PPC |
49 | bool | 53 | bool |
50 | default y | 54 | default y |
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index 34f5c2e074c9..ae354d65b82c 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile | |||
@@ -7,7 +7,6 @@ obj-y := string.o strcase.o | |||
7 | obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o | 7 | obj-$(CONFIG_PPC32) += div64.o copy_32.o checksum_32.o |
8 | endif | 8 | endif |
9 | 9 | ||
10 | obj-y += bitops.o | ||
11 | obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ | 10 | obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ |
12 | memcpy_64.o usercopy_64.o mem_64.o string.o \ | 11 | memcpy_64.o usercopy_64.o mem_64.o string.o \ |
13 | strcase.o | 12 | strcase.o |
diff --git a/arch/powerpc/lib/bitops.c b/arch/powerpc/lib/bitops.c deleted file mode 100644 index f68ad71a0187..000000000000 --- a/arch/powerpc/lib/bitops.c +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | #include <linux/types.h> | ||
2 | #include <linux/module.h> | ||
3 | #include <asm/byteorder.h> | ||
4 | #include <asm/bitops.h> | ||
5 | |||
6 | /** | ||
7 | * find_next_bit - find the next set bit in a memory region | ||
8 | * @addr: The address to base the search on | ||
9 | * @offset: The bitnumber to start searching at | ||
10 | * @size: The maximum size to search | ||
11 | */ | ||
12 | unsigned long find_next_bit(const unsigned long *addr, unsigned long size, | ||
13 | unsigned long offset) | ||
14 | { | ||
15 | const unsigned long *p = addr + BITOP_WORD(offset); | ||
16 | unsigned long result = offset & ~(BITS_PER_LONG-1); | ||
17 | unsigned long tmp; | ||
18 | |||
19 | if (offset >= size) | ||
20 | return size; | ||
21 | size -= result; | ||
22 | offset %= BITS_PER_LONG; | ||
23 | if (offset) { | ||
24 | tmp = *(p++); | ||
25 | tmp &= (~0UL << offset); | ||
26 | if (size < BITS_PER_LONG) | ||
27 | goto found_first; | ||
28 | if (tmp) | ||
29 | goto found_middle; | ||
30 | size -= BITS_PER_LONG; | ||
31 | result += BITS_PER_LONG; | ||
32 | } | ||
33 | while (size & ~(BITS_PER_LONG-1)) { | ||
34 | if ((tmp = *(p++))) | ||
35 | goto found_middle; | ||
36 | result += BITS_PER_LONG; | ||
37 | size -= BITS_PER_LONG; | ||
38 | } | ||
39 | if (!size) | ||
40 | return result; | ||
41 | tmp = *p; | ||
42 | |||
43 | found_first: | ||
44 | tmp &= (~0UL >> (BITS_PER_LONG - size)); | ||
45 | if (tmp == 0UL) /* Are any bits set? */ | ||
46 | return result + size; /* Nope. */ | ||
47 | found_middle: | ||
48 | return result + __ffs(tmp); | ||
49 | } | ||
50 | EXPORT_SYMBOL(find_next_bit); | ||
51 | |||
52 | /* | ||
53 | * This implementation of find_{first,next}_zero_bit was stolen from | ||
54 | * Linus' asm-alpha/bitops.h. | ||
55 | */ | ||
56 | unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, | ||
57 | unsigned long offset) | ||
58 | { | ||
59 | const unsigned long *p = addr + BITOP_WORD(offset); | ||
60 | unsigned long result = offset & ~(BITS_PER_LONG-1); | ||
61 | unsigned long tmp; | ||
62 | |||
63 | if (offset >= size) | ||
64 | return size; | ||
65 | size -= result; | ||
66 | offset %= BITS_PER_LONG; | ||
67 | if (offset) { | ||
68 | tmp = *(p++); | ||
69 | tmp |= ~0UL >> (BITS_PER_LONG - offset); | ||
70 | if (size < BITS_PER_LONG) | ||
71 | goto found_first; | ||
72 | if (~tmp) | ||
73 | goto found_middle; | ||
74 | size -= BITS_PER_LONG; | ||
75 | result += BITS_PER_LONG; | ||
76 | } | ||
77 | while (size & ~(BITS_PER_LONG-1)) { | ||
78 | if (~(tmp = *(p++))) | ||
79 | goto found_middle; | ||
80 | result += BITS_PER_LONG; | ||
81 | size -= BITS_PER_LONG; | ||
82 | } | ||
83 | if (!size) | ||
84 | return result; | ||
85 | tmp = *p; | ||
86 | |||
87 | found_first: | ||
88 | tmp |= ~0UL << size; | ||
89 | if (tmp == ~0UL) /* Are any bits zero? */ | ||
90 | return result + size; /* Nope. */ | ||
91 | found_middle: | ||
92 | return result + ffz(tmp); | ||
93 | } | ||
94 | EXPORT_SYMBOL(find_next_zero_bit); | ||
95 | |||
96 | static inline unsigned int ext2_ilog2(unsigned int x) | ||
97 | { | ||
98 | int lz; | ||
99 | |||
100 | asm("cntlzw %0,%1": "=r"(lz):"r"(x)); | ||
101 | return 31 - lz; | ||
102 | } | ||
103 | |||
104 | static inline unsigned int ext2_ffz(unsigned int x) | ||
105 | { | ||
106 | u32 rc; | ||
107 | if ((x = ~x) == 0) | ||
108 | return 32; | ||
109 | rc = ext2_ilog2(x & -x); | ||
110 | return rc; | ||
111 | } | ||
112 | |||
113 | unsigned long find_next_zero_le_bit(const unsigned long *addr, | ||
114 | unsigned long size, unsigned long offset) | ||
115 | { | ||
116 | const unsigned int *p = ((const unsigned int *)addr) + (offset >> 5); | ||
117 | unsigned int result = offset & ~31; | ||
118 | unsigned int tmp; | ||
119 | |||
120 | if (offset >= size) | ||
121 | return size; | ||
122 | size -= result; | ||
123 | offset &= 31; | ||
124 | if (offset) { | ||
125 | tmp = cpu_to_le32p(p++); | ||
126 | tmp |= ~0U >> (32 - offset); /* bug or feature ? */ | ||
127 | if (size < 32) | ||
128 | goto found_first; | ||
129 | if (tmp != ~0) | ||
130 | goto found_middle; | ||
131 | size -= 32; | ||
132 | result += 32; | ||
133 | } | ||
134 | while (size >= 32) { | ||
135 | if ((tmp = cpu_to_le32p(p++)) != ~0) | ||
136 | goto found_middle; | ||
137 | result += 32; | ||
138 | size -= 32; | ||
139 | } | ||
140 | if (!size) | ||
141 | return result; | ||
142 | tmp = cpu_to_le32p(p); | ||
143 | found_first: | ||
144 | tmp |= ~0 << size; | ||
145 | if (tmp == ~0) /* Are any bits zero? */ | ||
146 | return result + size; /* Nope. */ | ||
147 | found_middle: | ||
148 | return result + ext2_ffz(tmp); | ||
149 | } | ||
150 | EXPORT_SYMBOL(find_next_zero_le_bit); | ||