[media] cx231xx: use v4l2 core function to create the MC graph
[cascardo/linux.git] / lib / libcrc32c.c
index b3131f5..74a54b7 100644 (file)
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/crc32c.h>
 
 static struct crypto_shash *tfm;
 
 u32 crc32c(u32 crc, const void *address, unsigned int length)
 {
-       struct {
-               struct shash_desc shash;
-               char ctx[crypto_shash_descsize(tfm)];
-       } desc;
+       SHASH_DESC_ON_STACK(shash, tfm);
+       u32 *ctx = (u32 *)shash_desc_ctx(shash);
        int err;
 
-       desc.shash.tfm = tfm;
-       desc.shash.flags = 0;
-       *(u32 *)desc.ctx = crc;
+       shash->tfm = tfm;
+       shash->flags = 0;
+       *ctx = crc;
 
-       err = crypto_shash_update(&desc.shash, address, length);
+       err = crypto_shash_update(shash, address, length);
        BUG_ON(err);
 
-       return *(u32 *)desc.ctx;
+       return *ctx;
 }
 
 EXPORT_SYMBOL(crc32c);
@@ -76,3 +75,4 @@ module_exit(libcrc32c_mod_fini);
 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations");
 MODULE_LICENSE("GPL");
+MODULE_SOFTDEP("pre: crc32c");