diff options
Diffstat (limited to 'firmware/2lib/2crc8.c')
-rw-r--r-- | firmware/2lib/2crc8.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/firmware/2lib/2crc8.c b/firmware/2lib/2crc8.c index 9df0a00f..d5284de6 100644 --- a/firmware/2lib/2crc8.c +++ b/firmware/2lib/2crc8.c @@ -1,21 +1,23 @@ /* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. + * + * Very simple 8-bit CRC function. */ #include "2sysincludes.h" #include "2crc8.h" +/* Uses CRC-8 ITU version, with x^8 + x^2 + x + 1 polynomial. + Note that result will evaluate to zero for a buffer of all zeroes. */ uint8_t vb2_crc8(const void *vptr, uint32_t size) { const uint8_t *data = vptr; unsigned crc = 0; uint32_t i, j; - /* - * Calculate CRC-8 directly. A table-based algorithm would be faster, - * but for only a few bytes it isn't worth the code size. - */ + /* Calculate CRC-8 directly. A table-based algorithm would be faster, + but for only a few bytes it isn't worth the code size. */ for (j = size; j; j--, data++) { crc ^= (*data << 8); for(i = 8; i; i--) { |