summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-03-04 11:53:15 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-04 14:19:26 +0100
commit2d13b856604bd9486f5190438e695d0708dc5017 (patch)
treee2e514d2eeb7ccdfa8035bbeb501ab4867ce9174
parent74de1afbd2ed4262d4105b12641de0c5c487d930 (diff)
downloadbarebox-2d13b856604bd9486f5190438e695d0708dc5017.tar.gz
barebox-2d13b856604bd9486f5190438e695d0708dc5017.tar.xz
crc: Add PBL variant for crc_itu_t()
Enable crc_itu_t() for PBL. For the PBL use the slower-but-smaller variant without table. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--crypto/Makefile2
-rw-r--r--include/crc.h16
2 files changed, 17 insertions, 1 deletions
diff --git a/crypto/Makefile b/crypto/Makefile
index 0014b0f4ce..3402f57255 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -1,5 +1,5 @@
obj-$(CONFIG_CRC32) += crc32.o
-obj-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
+obj-pbl-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
obj-$(CONFIG_CRC7) += crc7.o
obj-$(CONFIG_DIGEST) += digest.o
obj-$(CONFIG_DIGEST_CRC32_GENERIC) += crc32_digest.o
diff --git a/include/crc.h b/include/crc.h
index 317f6f5494..a67388f732 100644
--- a/include/crc.h
+++ b/include/crc.h
@@ -13,10 +13,26 @@ extern u16 const crc_itu_t_table[256];
extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len);
+#ifdef __PBL__
+static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
+{
+ int i;
+
+ crc = crc ^ data << 8;
+ for (i = 0; i < 8; ++i) {
+ if (crc & 0x8000)
+ crc = crc << 1 ^ 0x1021;
+ else
+ crc = crc << 1;
+ }
+ return crc;
+}
+#else
static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
{
return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff];
}
+#endif
uint32_t crc32(uint32_t, const void *, unsigned int);
uint32_t crc32_no_comp(uint32_t, const void *, unsigned int);