]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - crypto/crc32_generic.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
[linux.git] / crypto / crc32_generic.c
index 718cbce8d1695f5a3c064fb7ab5618b6fe5c4e28..00facd27bcc290549c7aa9277e02a37a39b507b3 100644 (file)
@@ -29,6 +29,7 @@
  * This is crypto api shash wrappers to crc32_le.
  */
 
+#include <asm/unaligned.h>
 #include <linux/crc32.h>
 #include <crypto/internal/hash.h>
 #include <linux/init.h>
 #define CHKSUM_BLOCK_SIZE      1
 #define CHKSUM_DIGEST_SIZE     4
 
-static u32 __crc32_le(u32 crc, unsigned char const *p, size_t len)
-{
-       return crc32_le(crc, p, len);
-}
-
 /** No default init with ~0 */
 static int crc32_cra_init(struct crypto_tfm *tfm)
 {
@@ -54,7 +50,6 @@ static int crc32_cra_init(struct crypto_tfm *tfm)
        return 0;
 }
 
-
 /*
  * Setting the seed allows arbitrary accumulators and flexible XOR policy
  * If your algorithm starts with ~0, then XOR with ~0 before you set
@@ -69,7 +64,7 @@ static int crc32_setkey(struct crypto_shash *hash, const u8 *key,
                crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
                return -EINVAL;
        }
-       *mctx = le32_to_cpup((__le32 *)key);
+       *mctx = get_unaligned_le32(key);
        return 0;
 }
 
@@ -88,7 +83,7 @@ static int crc32_update(struct shash_desc *desc, const u8 *data,
 {
        u32 *crcp = shash_desc_ctx(desc);
 
-       *crcp = __crc32_le(*crcp, data, len);
+       *crcp = crc32_le(*crcp, data, len);
        return 0;
 }
 
@@ -96,7 +91,7 @@ static int crc32_update(struct shash_desc *desc, const u8 *data,
 static int __crc32_finup(u32 *crcp, const u8 *data, unsigned int len,
                         u8 *out)
 {
-       *(__le32 *)out = cpu_to_le32(__crc32_le(*crcp, data, len));
+       put_unaligned_le32(crc32_le(*crcp, data, len), out);
        return 0;
 }
 
@@ -110,7 +105,7 @@ static int crc32_final(struct shash_desc *desc, u8 *out)
 {
        u32 *crcp = shash_desc_ctx(desc);
 
-       *(__le32 *)out = cpu_to_le32p(crcp);
+       put_unaligned_le32(*crcp, out);
        return 0;
 }