[PATCH 2/6] crc: Add PBL variant for crc_itu_t()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Enable crc_itu_t() for PBL. For the PBL use the slower-but-smaller
variant without table.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 crypto/Makefile |  2 +-
 include/crc.h   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

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);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux