diff options
author | Akinobu Mita <mita@miraclelinux.com> | 2006-03-26 04:39:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-26 11:57:15 -0500 |
commit | 37d54111c133bea05fbae9dfe6d3d61a1b19c09b (patch) | |
tree | 780d15232a465815b96e2cd22c85b3e05f2b1238 | |
parent | e9bebd6f3acee68fa07d44726895b40733cb1dc0 (diff) |
[PATCH] bitops: hweight() related cleanup
By defining generic hweight*() routines
- hweight64() will be defined on all architectures
- hweight_long() will use architecture optimized hweight32() or hweight64()
I found two possible cleanups by these reasons.
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/ieee1394/highlevel.c | 3 | ||||
-rw-r--r-- | lib/bitmap.c | 19 |
2 files changed, 3 insertions, 19 deletions
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c index 734b121a0554..491e6032bdec 100644 --- a/drivers/ieee1394/highlevel.c +++ b/drivers/ieee1394/highlevel.c | |||
@@ -306,8 +306,7 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, | |||
306 | u64 align_mask = ~(alignment - 1); | 306 | u64 align_mask = ~(alignment - 1); |
307 | 307 | ||
308 | if ((alignment & 3) || (alignment > 0x800000000000ULL) || | 308 | if ((alignment & 3) || (alignment > 0x800000000000ULL) || |
309 | ((hweight32(alignment >> 32) + | 309 | (hweight64(alignment) != 1)) { |
310 | hweight32(alignment & 0xffffffff) != 1))) { | ||
311 | HPSB_ERR("%s called with invalid alignment: 0x%048llx", | 310 | HPSB_ERR("%s called with invalid alignment: 0x%048llx", |
312 | __FUNCTION__, (unsigned long long)alignment); | 311 | __FUNCTION__, (unsigned long long)alignment); |
313 | return retval; | 312 | return retval; |
diff --git a/lib/bitmap.c b/lib/bitmap.c index 8acab0e176ef..ed2ae3b0cd06 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -253,33 +253,18 @@ int __bitmap_subset(const unsigned long *bitmap1, | |||
253 | } | 253 | } |
254 | EXPORT_SYMBOL(__bitmap_subset); | 254 | EXPORT_SYMBOL(__bitmap_subset); |
255 | 255 | ||
256 | #if BITS_PER_LONG == 32 | ||
257 | int __bitmap_weight(const unsigned long *bitmap, int bits) | 256 | int __bitmap_weight(const unsigned long *bitmap, int bits) |
258 | { | 257 | { |
259 | int k, w = 0, lim = bits/BITS_PER_LONG; | 258 | int k, w = 0, lim = bits/BITS_PER_LONG; |
260 | 259 | ||
261 | for (k = 0; k < lim; k++) | 260 | for (k = 0; k < lim; k++) |
262 | w += hweight32(bitmap[k]); | 261 | w += hweight_long(bitmap[k]); |
263 | 262 | ||
264 | if (bits % BITS_PER_LONG) | 263 | if (bits % BITS_PER_LONG) |
265 | w += hweight32(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); | 264 | w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); |
266 | 265 | ||
267 | return w; | 266 | return w; |
268 | } | 267 | } |
269 | #else | ||
270 | int __bitmap_weight(const unsigned long *bitmap, int bits) | ||
271 | { | ||
272 | int k, w = 0, lim = bits/BITS_PER_LONG; | ||
273 | |||
274 | for (k = 0; k < lim; k++) | ||
275 | w += hweight64(bitmap[k]); | ||
276 | |||
277 | if (bits % BITS_PER_LONG) | ||
278 | w += hweight64(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); | ||
279 | |||
280 | return w; | ||
281 | } | ||
282 | #endif | ||
283 | EXPORT_SYMBOL(__bitmap_weight); | 268 | EXPORT_SYMBOL(__bitmap_weight); |
284 | 269 | ||
285 | /* | 270 | /* |