diff options
author | Bob Pearson <rpearson@systemfabricworks.com> | 2012-03-23 15:02:23 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 16:58:37 -0700 |
commit | 9a1dbf6a29694c9d81b498019f103aee0f8b5b6c (patch) | |
tree | 1f331fa108ea29ccf06a7b5816da4dbcaa12bf2d /lib/crc32defs.h | |
parent | ce4320ddda4c2520fe77194d3c801ad4e8a8aa11 (diff) | |
download | linux-3.10-9a1dbf6a29694c9d81b498019f103aee0f8b5b6c.tar.gz linux-3.10-9a1dbf6a29694c9d81b498019f103aee0f8b5b6c.tar.bz2 linux-3.10-9a1dbf6a29694c9d81b498019f103aee0f8b5b6c.zip |
crc32: make CRC_*_BITS definition correspond to actual bit counts
crc32.c provides a choice of one of several algorithms for computing the
LSB and LSB versions of the CRC32 checksum based on the parameters
CRC_LE_BITS and CRC_BE_BITS.
In the original version the values 1, 2, 4 and 8 respectively selected
versions of the alrogithm that computed the crc 1, 2, 4 and 32 bits as a
time.
This patch series adds a new version that computes the CRC 64 bits at a
time. To make things easier to understand the parameter has been
reinterpreted to actually stand for the number of bits processed in each
step of the algorithm so that the old value 8 has been replaced with the
value 32.
This also allows us to add in a widely used crc algorithm that computes
the crc 8 bits at a time called the Sarwate algorithm.
[djwong@us.ibm.com: Minor changelog tweaks]
Signed-off-by: Bob Pearson <rpearson@systemfabricworks.com>
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/crc32defs.h')
-rw-r--r-- | lib/crc32defs.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/crc32defs.h b/lib/crc32defs.h index f5a54017657..daa3a5e85f6 100644 --- a/lib/crc32defs.h +++ b/lib/crc32defs.h @@ -6,27 +6,29 @@ #define CRCPOLY_LE 0xedb88320 #define CRCPOLY_BE 0x04c11db7 -/* How many bits at a time to use. Requires a table of 4<<CRC_xx_BITS bytes. */ -/* For less performance-sensitive, use 4 */ +/* How many bits at a time to use. Valid values are 1, 2, 4, 8, and 32. */ +/* For less performance-sensitive, use 4 or 8 */ #ifndef CRC_LE_BITS -# define CRC_LE_BITS 8 +# define CRC_LE_BITS 32 #endif #ifndef CRC_BE_BITS -# define CRC_BE_BITS 8 +# define CRC_BE_BITS 32 #endif /* * Little-endian CRC computation. Used with serial bit streams sent * lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC. */ -#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1 -# error CRC_LE_BITS must be a power of 2 between 1 and 8 +#if CRC_LE_BITS > 32 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \ + CRC_LE_BITS & CRC_LE_BITS-1 +# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32}" #endif /* * Big-endian CRC computation. Used with serial bit streams sent * msbit-first. Be sure to use cpu_to_be32() to append the computed CRC. */ -#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1 -# error CRC_BE_BITS must be a power of 2 between 1 and 8 +#if CRC_BE_BITS > 32 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \ + CRC_BE_BITS & CRC_BE_BITS-1 +# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32}" #endif |