summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/crc.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/src/crc.c')
-rw-r--r--zephyr/shim/src/crc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/zephyr/shim/src/crc.c b/zephyr/shim/src/crc.c
new file mode 100644
index 0000000000..5c726619ee
--- /dev/null
+++ b/zephyr/shim/src/crc.c
@@ -0,0 +1,21 @@
+/* Copyright 2020 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 <sys/crc.h>
+
+#include "crc8.h"
+
+/* Polynomial representation for x^8 + x^2 + x + 1 is 0x07 */
+#define SMBUS_POLYNOMIAL 0x07
+
+inline uint8_t cros_crc8(const uint8_t *data, int len)
+{
+ return crc8(data, len, SMBUS_POLYNOMIAL, 0, false);
+}
+
+uint8_t cros_crc8_arg(const uint8_t *data, int len, uint8_t previous_crc)
+{
+ return crc8(data, len, SMBUS_POLYNOMIAL, previous_crc, false);
+}