summaryrefslogtreecommitdiff
path: root/firmware/lib/crc8.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib/crc8.c')
-rw-r--r--firmware/lib/crc8.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/firmware/lib/crc8.c b/firmware/lib/crc8.c
index fa770253..b0ee8679 100644
--- a/firmware/lib/crc8.c
+++ b/firmware/lib/crc8.c
@@ -1,28 +1,28 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 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.
*/
#include "crc8.h"
-/* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A
- * table-based algorithm would be faster, but for only a few bytes it isn't
- * worth the code size. */
-uint8_t Crc8(const void* vptr, int len) {
- const uint8_t *data = vptr;
- unsigned crc = 0;
- int i, j;
+/**
+ * Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A table-based
+ * algorithm would be faster, but for only a few bytes it isn't worth the code
+ * size. */
+uint8_t Crc8(const void *vptr, int len)
+{
+ const uint8_t *data = vptr;
+ unsigned crc = 0;
+ int i, j;
- for (j = len; j; j--, data++) {
- crc ^= (*data << 8);
- for(i = 8; i; i--) {
- if (crc & 0x8000)
- crc ^= (0x1070 << 3);
- crc <<= 1;
- }
- }
+ for (j = len; j; j--, data++) {
+ crc ^= (*data << 8);
+ for(i = 8; i; i--) {
+ if (crc & 0x8000)
+ crc ^= (0x1070 << 3);
+ crc <<= 1;
+ }
+ }
- return (uint8_t)(crc >> 8);
+ return (uint8_t)(crc >> 8);
}
-
-