mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/6] crc: Add PBL variant for crc_itu_t()
Date: Mon,  4 Mar 2019 12:38:19 +0100	[thread overview]
Message-ID: <20190304113823.21535-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190304113823.21535-1-s.hauer@pengutronix.de>

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>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-03-04 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 11:38 [PATCH 0/6] SPD EEPROM improvements Sascha Hauer
2019-03-04 11:38 ` [PATCH 1/6] crc: import crc_itu_t() from kernel Sascha Hauer
2019-03-04 11:50   ` Sam Ravnborg
2019-03-04 13:19     ` Sascha Hauer
2019-03-04 11:38 ` Sascha Hauer [this message]
2019-03-04 11:38 ` [PATCH 3/6] ddr_spd: Update from U-Boot Sascha Hauer
2019-03-04 11:38 ` [PATCH 4/6] ddr_spd: Add function to read eeprom Sascha Hauer
2019-03-04 11:53   ` Sam Ravnborg
2019-03-04 12:02   ` Sam Ravnborg
2019-03-04 13:22     ` Sascha Hauer
2019-03-04 11:38 ` [PATCH 5/6] ddr_spd: provide common SPD type Sascha Hauer
2019-03-04 11:38 ` [PATCH 6/6] ddr_spd: Enable in PBL Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190304113823.21535-3-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox