1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2012 Freescale Semiconductor, Inc.
5 * Cleaned up and refactored by Charles Manning.
9 static uint32_t crc_table[256];
10 static int crc_table_valid;
12 static void make_crc_table(void)
16 uint32_t poly; /* polynomial exclusive-or pattern */
22 * the polynomial used by PBL is 1 + x1 + x2 + x4 + x5 + x7 + x8 + x10
23 * + x11 + x12 + x16 + x22 + x23 + x26 + x32.
27 for (i = 0; i < 256; i++) {
29 for (j = 0; j < 8; j++) {
30 if (mask & 0x80000000)
31 mask = (mask << 1) ^ poly;
41 uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len)
50 for (i = 0; i < len; i++)
51 crc32_val = (crc32_val << 8) ^
52 crc_table[(crc32_val >> 24) ^ (*buf++ & 0xff)];