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] crypto: crc32: implement crc32() with crc32_no_comp()
Date: Wed, 13 Dec 2023 15:00:04 +0100	[thread overview]
Message-ID: <20231213140004.898488-1-s.hauer@pengutronix.de> (raw)

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 crypto/crc32.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/crypto/crc32.c b/crypto/crc32.c
index 287dfa3303..7e969cd18e 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -77,28 +77,6 @@ static void make_crc_table(void)
 #define DO4(buf)  DO2(buf); DO2(buf);
 #define DO8(buf)  DO4(buf); DO4(buf);
 
-STATIC uint32_t crc32(uint32_t crc, const void *_buf, unsigned int len)
-{
-	const unsigned char *buf = _buf;
-
-	make_crc_table();
-
-	crc = crc ^ 0xffffffffL;
-	while (len >= 8) {
-		DO8(buf);
-		len -= 8;
-	}
-	if (len)
-		do {
-			DO1(buf);
-		} while (--len);
-	return crc ^ 0xffffffffL;
-}
-
-#ifdef __BAREBOX__
-EXPORT_SYMBOL(crc32);
-#endif
-
 /* No ones complement version. JFFS2 (and other things ?)
  * don't use ones compliment in their CRC calculations.
  */
@@ -120,6 +98,15 @@ STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len)
 	return crc;
 }
 
+STATIC uint32_t crc32(uint32_t crc, const void *buf, unsigned int len)
+{
+	return ~crc32_no_comp(~crc, buf, len);
+}
+
+#ifdef __BAREBOX__
+EXPORT_SYMBOL(crc32);
+#endif
+
 STATIC uint32_t crc32_be(uint32_t crc, const void *_buf, unsigned int len)
 {
 	const unsigned char *buf = _buf;
-- 
2.39.2




                 reply	other threads:[~2023-12-13 14:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231213140004.898488-1-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