~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/libcrc32c.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/libcrc32c.c (Version linux-6.12-rc7) and /lib/libcrc32c.c (Version linux-5.5.19)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /* 
  3  * CRC32C                                           3  * CRC32C
  4  *@Article{castagnoli-crc,                          4  *@Article{castagnoli-crc,
  5  * author =       { Guy Castagnoli and Stefan       5  * author =       { Guy Castagnoli and Stefan Braeuer and Martin Herrman},
  6  * title =        {{Optimization of Cyclic Red      6  * title =        {{Optimization of Cyclic Redundancy-Check Codes with 24
  7  *                 and 32 Parity Bits}},            7  *                 and 32 Parity Bits}},
  8  * journal =      IEEE Transactions on Communi      8  * journal =      IEEE Transactions on Communication,
  9  * year =         {1993},                           9  * year =         {1993},
 10  * volume =       {41},                            10  * volume =       {41},
 11  * number =       {6},                             11  * number =       {6},
 12  * pages =        {},                              12  * pages =        {},
 13  * month =        {June},                          13  * month =        {June},
 14  *}                                                14  *}
 15  * Used by the iSCSI driver, possibly others,  !!  15  * Used by the iSCSI driver, possibly others, and derived from the
 16  * the iscsi-crc.c module of the linux-iscsi d     16  * the iscsi-crc.c module of the linux-iscsi driver at
 17  * http://linux-iscsi.sourceforge.net.             17  * http://linux-iscsi.sourceforge.net.
 18  *                                                 18  *
 19  * Following the example of lib/crc32, this fu     19  * Following the example of lib/crc32, this function is intended to be
 20  * flexible and useful for all users.  Modules     20  * flexible and useful for all users.  Modules that currently have their
 21  * own crc32c, but hopefully may be able to us     21  * own crc32c, but hopefully may be able to use this one are:
 22  *  net/sctp (please add all your doco to here     22  *  net/sctp (please add all your doco to here if you change to
 23  *            use this one!)                       23  *            use this one!)
 24  *  <endoflist>                                    24  *  <endoflist>
 25  *                                                 25  *
 26  * Copyright (c) 2004 Cisco Systems, Inc.          26  * Copyright (c) 2004 Cisco Systems, Inc.
 27  */                                                27  */
 28                                                    28 
 29 #include <crypto/hash.h>                           29 #include <crypto/hash.h>
 30 #include <linux/err.h>                             30 #include <linux/err.h>
 31 #include <linux/init.h>                            31 #include <linux/init.h>
 32 #include <linux/kernel.h>                          32 #include <linux/kernel.h>
 33 #include <linux/module.h>                          33 #include <linux/module.h>
 34 #include <linux/crc32c.h>                          34 #include <linux/crc32c.h>
 35                                                    35 
 36 static struct crypto_shash *tfm;                   36 static struct crypto_shash *tfm;
 37                                                    37 
 38 u32 crc32c(u32 crc, const void *address, unsig     38 u32 crc32c(u32 crc, const void *address, unsigned int length)
 39 {                                                  39 {
 40         SHASH_DESC_ON_STACK(shash, tfm);           40         SHASH_DESC_ON_STACK(shash, tfm);
 41         u32 ret, *ctx = (u32 *)shash_desc_ctx(     41         u32 ret, *ctx = (u32 *)shash_desc_ctx(shash);
 42         int err;                                   42         int err;
 43                                                    43 
 44         shash->tfm = tfm;                          44         shash->tfm = tfm;
 45         *ctx = crc;                                45         *ctx = crc;
 46                                                    46 
 47         err = crypto_shash_update(shash, addre     47         err = crypto_shash_update(shash, address, length);
 48         BUG_ON(err);                               48         BUG_ON(err);
 49                                                    49 
 50         ret = *ctx;                                50         ret = *ctx;
 51         barrier_data(ctx);                         51         barrier_data(ctx);
 52         return ret;                                52         return ret;
 53 }                                                  53 }
 54                                                    54 
 55 EXPORT_SYMBOL(crc32c);                             55 EXPORT_SYMBOL(crc32c);
 56                                                    56 
 57 static int __init libcrc32c_mod_init(void)         57 static int __init libcrc32c_mod_init(void)
 58 {                                                  58 {
 59         tfm = crypto_alloc_shash("crc32c", 0,      59         tfm = crypto_alloc_shash("crc32c", 0, 0);
 60         return PTR_ERR_OR_ZERO(tfm);               60         return PTR_ERR_OR_ZERO(tfm);
 61 }                                                  61 }
 62                                                    62 
 63 static void __exit libcrc32c_mod_fini(void)        63 static void __exit libcrc32c_mod_fini(void)
 64 {                                                  64 {
 65         crypto_free_shash(tfm);                    65         crypto_free_shash(tfm);
 66 }                                                  66 }
                                                   >>  67 
                                                   >>  68 const char *crc32c_impl(void)
                                                   >>  69 {
                                                   >>  70         return crypto_shash_driver_name(tfm);
                                                   >>  71 }
                                                   >>  72 EXPORT_SYMBOL(crc32c_impl);
 67                                                    73 
 68 module_init(libcrc32c_mod_init);                   74 module_init(libcrc32c_mod_init);
 69 module_exit(libcrc32c_mod_fini);                   75 module_exit(libcrc32c_mod_fini);
 70                                                    76 
 71 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.co     77 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
 72 MODULE_DESCRIPTION("CRC32c (Castagnoli) calcul     78 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations");
 73 MODULE_LICENSE("GPL");                             79 MODULE_LICENSE("GPL");
 74 MODULE_SOFTDEP("pre: crc32c");                     80 MODULE_SOFTDEP("pre: crc32c");
 75                                                    81 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php