summaryrefslogtreecommitdiffstats
path: root/include/linux/crc8.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-11-10 10:26:47 -0700
committerSimon Glass <sjg@chromium.org>2014-01-08 17:20:34 -0700
commit60d18d3fe9d1a5db663711063cd0d5c915af377a (patch)
tree82f1144ddcc272992f4999fac37bda8a816ec991 /include/linux/crc8.h
parente7be18225fbea76d1f0034b224f0d1e60f07cfcf (diff)
downloadblackbird-obmc-uboot-60d18d3fe9d1a5db663711063cd0d5c915af377a.tar.gz
blackbird-obmc-uboot-60d18d3fe9d1a5db663711063cd0d5c915af377a.zip
Add crc8 routine
Add an implementation of the CRC8 algorithm. This is required by the TPM emulation, but is probably useful to U-Boot in general. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/linux/crc8.h')
-rw-r--r--include/linux/crc8.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/crc8.h b/include/linux/crc8.h
new file mode 100644
index 0000000000..b5fd2ac9d6
--- /dev/null
+++ b/include/linux/crc8.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+
+#ifndef __linux_crc8_h
+#define __linux_crc8_h
+
+/**
+ * crc8() - Calculate and return CRC-8 of the data
+ *
+ * This uses an 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
+ *
+ * @vptr: Buffer to checksum
+ * @len: Length of buffer in bytes
+ * @return CRC8 checksum
+ */
+unsigned int crc8(const unsigned char *vptr, int len);
+
+#endif
OpenPOWER on IntegriCloud