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

[PATCH] crc32: replace bitreverse by bitrev32

This patch replaces bitreverse() by bitrev32. The only users of bitreverse()
are crc32 itself and via-velocity.

Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
906d66df a5cfc1ec

+9 -26
+1 -1
drivers/net/via-velocity.c
··· 3132 3132 } 3133 3133 /* Finally, invert the result once to get the correct data */ 3134 3134 crc = ~crc; 3135 - return bitreverse(crc) >> 16; 3135 + return bitrev32(crc) >> 16; 3136 3136 } 3137 3137 3138 3138 /**
+2 -2
include/linux/crc32.h
··· 6 6 #define _LINUX_CRC32_H 7 7 8 8 #include <linux/types.h> 9 + #include <linux/bitrev.h> 9 10 10 11 extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len); 11 12 extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len); 12 - extern u32 bitreverse(u32 in); 13 13 14 14 #define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)data, length) 15 15 ··· 21 21 * is in bit nr 0], thus it must be reversed before use. Except for 22 22 * nics that bit swap the result internally... 23 23 */ 24 - #define ether_crc(length, data) bitreverse(crc32_le(~0, data, length)) 24 + #define ether_crc(length, data) bitrev32(crc32_le(~0, data, length)) 25 25 #define ether_crc_le(length, data) crc32_le(~0, data, length) 26 26 27 27 #endif /* _LINUX_CRC32_H */
+1
lib/Kconfig
··· 26 26 config CRC32 27 27 tristate "CRC32 functions" 28 28 default y 29 + select BITREVERSE 29 30 help 30 31 This option is provided for the case where no in-kernel-tree 31 32 modules require CRC32 functions, but a module built outside the
+5 -23
lib/crc32.c
··· 235 235 } 236 236 #endif 237 237 238 - /** 239 - * bitreverse - reverse the order of bits in a u32 value 240 - * @x: value to be bit-reversed 241 - */ 242 - u32 bitreverse(u32 x) 243 - { 244 - x = (x >> 16) | (x << 16); 245 - x = (x >> 8 & 0x00ff00ff) | (x << 8 & 0xff00ff00); 246 - x = (x >> 4 & 0x0f0f0f0f) | (x << 4 & 0xf0f0f0f0); 247 - x = (x >> 2 & 0x33333333) | (x << 2 & 0xcccccccc); 248 - x = (x >> 1 & 0x55555555) | (x << 1 & 0xaaaaaaaa); 249 - return x; 250 - } 251 - 252 238 EXPORT_SYMBOL(crc32_le); 253 239 EXPORT_SYMBOL(crc32_be); 254 - EXPORT_SYMBOL(bitreverse); 255 240 256 241 /* 257 242 * A brief CRC tutorial. ··· 385 400 static void bytereverse(unsigned char *buf, size_t len) 386 401 { 387 402 while (len--) { 388 - unsigned char x = *buf; 389 - x = (x >> 4) | (x << 4); 390 - x = (x >> 2 & 0x33) | (x << 2 & 0xcc); 391 - x = (x >> 1 & 0x55) | (x << 1 & 0xaa); 403 + unsigned char x = bitrev8(*buf); 392 404 *buf++ = x; 393 405 } 394 406 } ··· 442 460 /* Now swap it around for the other test */ 443 461 444 462 bytereverse(buf, len + 4); 445 - init = bitreverse(init); 446 - crc2 = bitreverse(crc1); 447 - if (crc1 != bitreverse(crc2)) 463 + init = bitrev32(init); 464 + crc2 = bitrev32(crc1); 465 + if (crc1 != bitrev32(crc2)) 448 466 printf("\nBit reversal fail: 0x%08x -> 0x%08x -> 0x%08x\n", 449 - crc1, crc2, bitreverse(crc2)); 467 + crc1, crc2, bitrev32(crc2)); 450 468 crc1 = crc32_le(init, buf, len); 451 469 if (crc1 != crc2) 452 470 printf("\nCRC endianness fail: 0x%08x != 0x%08x\n", crc1,