]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - lib/gen_crc32table.c
crc32: make CRC_*_BITS definition correspond to actual bit counts
[mirror_ubuntu-artful-kernel.git] / lib / gen_crc32table.c
index eced7696eb7c8f8592f213048cbf8b53d9c19897..99ac744848fb49ffe7303c1046d0e3bcf7cfa383 100644 (file)
@@ -4,8 +4,17 @@
 
 #define ENTRIES_PER_LINE 4
 
+#if CRC_LE_BITS <= 8
 #define LE_TABLE_SIZE (1 << CRC_LE_BITS)
+#else
+#define LE_TABLE_SIZE 256
+#endif
+
+#if CRC_BE_BITS <= 8
 #define BE_TABLE_SIZE (1 << CRC_BE_BITS)
+#else
+#define BE_TABLE_SIZE 256
+#endif
 
 static uint32_t crc32table_le[4][256];
 static uint32_t crc32table_be[4][256];
@@ -24,7 +33,7 @@ static void crc32init_le(void)
 
        crc32table_le[0][0] = 0;
 
-       for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
+       for (i = LE_TABLE_SIZE >> 1; i; i >>= 1) {
                crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
                for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
                        crc32table_le[0][i + j] = crc ^ crc32table_le[0][j];