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

TOMOYO Linux Cross Reference
Linux/crypto/842.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /crypto/842.c (Version linux-6.11.5) and /crypto/842.c (Version linux-5.13.19)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  * Cryptographic API for the 842 software comp      3  * Cryptographic API for the 842 software compression algorithm.
  4  *                                                  4  *
  5  * Copyright (C) IBM Corporation, 2011-2015         5  * Copyright (C) IBM Corporation, 2011-2015
  6  *                                                  6  *
  7  * Original Authors: Robert Jennings <rcj@linu      7  * Original Authors: Robert Jennings <rcj@linux.vnet.ibm.com>
  8  *                   Seth Jennings <sjenning@l      8  *                   Seth Jennings <sjenning@linux.vnet.ibm.com>
  9  *                                                  9  *
 10  * Rewrite: Dan Streetman <ddstreet@ieee.org>      10  * Rewrite: Dan Streetman <ddstreet@ieee.org>
 11  *                                                 11  *
 12  * This is the software implementation of comp     12  * This is the software implementation of compression and decompression using
 13  * the 842 format.  This uses the software 842     13  * the 842 format.  This uses the software 842 library at lib/842/ which is
 14  * only a reference implementation, and is ver     14  * only a reference implementation, and is very, very slow as compared to other
 15  * software compressors.  You probably do not      15  * software compressors.  You probably do not want to use this software
 16  * compression.  If you have access to the Pow     16  * compression.  If you have access to the PowerPC 842 compression hardware, you
 17  * want to use the 842 hardware compression in     17  * want to use the 842 hardware compression interface, which is at:
 18  * drivers/crypto/nx/nx-842-crypto.c               18  * drivers/crypto/nx/nx-842-crypto.c
 19  */                                                19  */
 20                                                    20 
 21 #include <linux/init.h>                            21 #include <linux/init.h>
 22 #include <linux/module.h>                          22 #include <linux/module.h>
 23 #include <linux/crypto.h>                          23 #include <linux/crypto.h>
 24 #include <linux/sw842.h>                           24 #include <linux/sw842.h>
 25 #include <crypto/internal/scompress.h>             25 #include <crypto/internal/scompress.h>
 26                                                    26 
 27 struct crypto842_ctx {                             27 struct crypto842_ctx {
 28         void *wmem;     /* working memory for      28         void *wmem;     /* working memory for compress */
 29 };                                                 29 };
 30                                                    30 
 31 static void *crypto842_alloc_ctx(struct crypto     31 static void *crypto842_alloc_ctx(struct crypto_scomp *tfm)
 32 {                                                  32 {
 33         void *ctx;                                 33         void *ctx;
 34                                                    34 
 35         ctx = kmalloc(SW842_MEM_COMPRESS, GFP_     35         ctx = kmalloc(SW842_MEM_COMPRESS, GFP_KERNEL);
 36         if (!ctx)                                  36         if (!ctx)
 37                 return ERR_PTR(-ENOMEM);           37                 return ERR_PTR(-ENOMEM);
 38                                                    38 
 39         return ctx;                                39         return ctx;
 40 }                                                  40 }
 41                                                    41 
 42 static int crypto842_init(struct crypto_tfm *t     42 static int crypto842_init(struct crypto_tfm *tfm)
 43 {                                                  43 {
 44         struct crypto842_ctx *ctx = crypto_tfm     44         struct crypto842_ctx *ctx = crypto_tfm_ctx(tfm);
 45                                                    45 
 46         ctx->wmem = crypto842_alloc_ctx(NULL);     46         ctx->wmem = crypto842_alloc_ctx(NULL);
 47         if (IS_ERR(ctx->wmem))                     47         if (IS_ERR(ctx->wmem))
 48                 return -ENOMEM;                    48                 return -ENOMEM;
 49                                                    49 
 50         return 0;                                  50         return 0;
 51 }                                                  51 }
 52                                                    52 
 53 static void crypto842_free_ctx(struct crypto_s     53 static void crypto842_free_ctx(struct crypto_scomp *tfm, void *ctx)
 54 {                                                  54 {
 55         kfree(ctx);                                55         kfree(ctx);
 56 }                                                  56 }
 57                                                    57 
 58 static void crypto842_exit(struct crypto_tfm *     58 static void crypto842_exit(struct crypto_tfm *tfm)
 59 {                                                  59 {
 60         struct crypto842_ctx *ctx = crypto_tfm     60         struct crypto842_ctx *ctx = crypto_tfm_ctx(tfm);
 61                                                    61 
 62         crypto842_free_ctx(NULL, ctx->wmem);       62         crypto842_free_ctx(NULL, ctx->wmem);
 63 }                                                  63 }
 64                                                    64 
 65 static int crypto842_compress(struct crypto_tf     65 static int crypto842_compress(struct crypto_tfm *tfm,
 66                               const u8 *src, u     66                               const u8 *src, unsigned int slen,
 67                               u8 *dst, unsigne     67                               u8 *dst, unsigned int *dlen)
 68 {                                                  68 {
 69         struct crypto842_ctx *ctx = crypto_tfm     69         struct crypto842_ctx *ctx = crypto_tfm_ctx(tfm);
 70                                                    70 
 71         return sw842_compress(src, slen, dst,      71         return sw842_compress(src, slen, dst, dlen, ctx->wmem);
 72 }                                                  72 }
 73                                                    73 
 74 static int crypto842_scompress(struct crypto_s     74 static int crypto842_scompress(struct crypto_scomp *tfm,
 75                                const u8 *src,      75                                const u8 *src, unsigned int slen,
 76                                u8 *dst, unsign     76                                u8 *dst, unsigned int *dlen, void *ctx)
 77 {                                                  77 {
 78         return sw842_compress(src, slen, dst,      78         return sw842_compress(src, slen, dst, dlen, ctx);
 79 }                                                  79 }
 80                                                    80 
 81 static int crypto842_decompress(struct crypto_     81 static int crypto842_decompress(struct crypto_tfm *tfm,
 82                                 const u8 *src,     82                                 const u8 *src, unsigned int slen,
 83                                 u8 *dst, unsig     83                                 u8 *dst, unsigned int *dlen)
 84 {                                                  84 {
 85         return sw842_decompress(src, slen, dst     85         return sw842_decompress(src, slen, dst, dlen);
 86 }                                                  86 }
 87                                                    87 
 88 static int crypto842_sdecompress(struct crypto     88 static int crypto842_sdecompress(struct crypto_scomp *tfm,
 89                                  const u8 *src     89                                  const u8 *src, unsigned int slen,
 90                                  u8 *dst, unsi     90                                  u8 *dst, unsigned int *dlen, void *ctx)
 91 {                                                  91 {
 92         return sw842_decompress(src, slen, dst     92         return sw842_decompress(src, slen, dst, dlen);
 93 }                                                  93 }
 94                                                    94 
 95 static struct crypto_alg alg = {                   95 static struct crypto_alg alg = {
 96         .cra_name               = "842",           96         .cra_name               = "842",
 97         .cra_driver_name        = "842-generic     97         .cra_driver_name        = "842-generic",
 98         .cra_priority           = 100,             98         .cra_priority           = 100,
 99         .cra_flags              = CRYPTO_ALG_T     99         .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
100         .cra_ctxsize            = sizeof(struc    100         .cra_ctxsize            = sizeof(struct crypto842_ctx),
101         .cra_module             = THIS_MODULE,    101         .cra_module             = THIS_MODULE,
102         .cra_init               = crypto842_in    102         .cra_init               = crypto842_init,
103         .cra_exit               = crypto842_ex    103         .cra_exit               = crypto842_exit,
104         .cra_u                  = { .compress     104         .cra_u                  = { .compress = {
105         .coa_compress           = crypto842_co    105         .coa_compress           = crypto842_compress,
106         .coa_decompress         = crypto842_de    106         .coa_decompress         = crypto842_decompress } }
107 };                                                107 };
108                                                   108 
109 static struct scomp_alg scomp = {                 109 static struct scomp_alg scomp = {
110         .alloc_ctx              = crypto842_al    110         .alloc_ctx              = crypto842_alloc_ctx,
111         .free_ctx               = crypto842_fr    111         .free_ctx               = crypto842_free_ctx,
112         .compress               = crypto842_sc    112         .compress               = crypto842_scompress,
113         .decompress             = crypto842_sd    113         .decompress             = crypto842_sdecompress,
114         .base                   = {               114         .base                   = {
115                 .cra_name       = "842",          115                 .cra_name       = "842",
116                 .cra_driver_name = "842-scomp"    116                 .cra_driver_name = "842-scomp",
117                 .cra_priority    = 100,           117                 .cra_priority    = 100,
118                 .cra_module      = THIS_MODULE    118                 .cra_module      = THIS_MODULE,
119         }                                         119         }
120 };                                                120 };
121                                                   121 
122 static int __init crypto842_mod_init(void)        122 static int __init crypto842_mod_init(void)
123 {                                                 123 {
124         int ret;                                  124         int ret;
125                                                   125 
126         ret = crypto_register_alg(&alg);          126         ret = crypto_register_alg(&alg);
127         if (ret)                                  127         if (ret)
128                 return ret;                       128                 return ret;
129                                                   129 
130         ret = crypto_register_scomp(&scomp);      130         ret = crypto_register_scomp(&scomp);
131         if (ret) {                                131         if (ret) {
132                 crypto_unregister_alg(&alg);      132                 crypto_unregister_alg(&alg);
133                 return ret;                       133                 return ret;
134         }                                         134         }
135                                                   135 
136         return ret;                               136         return ret;
137 }                                                 137 }
138 subsys_initcall(crypto842_mod_init);              138 subsys_initcall(crypto842_mod_init);
139                                                   139 
140 static void __exit crypto842_mod_exit(void)       140 static void __exit crypto842_mod_exit(void)
141 {                                                 141 {
142         crypto_unregister_alg(&alg);              142         crypto_unregister_alg(&alg);
143         crypto_unregister_scomp(&scomp);          143         crypto_unregister_scomp(&scomp);
144 }                                                 144 }
145 module_exit(crypto842_mod_exit);                  145 module_exit(crypto842_mod_exit);
146                                                   146 
147 MODULE_LICENSE("GPL");                            147 MODULE_LICENSE("GPL");
148 MODULE_DESCRIPTION("842 Software Compression A    148 MODULE_DESCRIPTION("842 Software Compression Algorithm");
149 MODULE_ALIAS_CRYPTO("842");                       149 MODULE_ALIAS_CRYPTO("842");
150 MODULE_ALIAS_CRYPTO("842-generic");               150 MODULE_ALIAS_CRYPTO("842-generic");
151 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.or    151 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
152                                                   152 

~ [ 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