[PATCH] crypto: crc32: implement crc32() with crc32_no_comp()

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

 



Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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





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

  Powered by Linux