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

TOMOYO Linux Cross Reference
Linux/crypto/lz4hc.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/lz4hc.c (Version linux-6.11.5) and /crypto/lz4hc.c (Version linux-2.6.32.71)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Cryptographic API.                             
  4  *                                                
  5  * Copyright (c) 2013 Chanho Min <chanho.min@l    
  6  */                                               
  7 #include <linux/init.h>                           
  8 #include <linux/module.h>                         
  9 #include <linux/crypto.h>                         
 10 #include <linux/vmalloc.h>                        
 11 #include <linux/lz4.h>                            
 12 #include <crypto/internal/scompress.h>            
 13                                                   
 14 struct lz4hc_ctx {                                
 15         void *lz4hc_comp_mem;                     
 16 };                                                
 17                                                   
 18 static void *lz4hc_alloc_ctx(struct crypto_sco    
 19 {                                                 
 20         void *ctx;                                
 21                                                   
 22         ctx = vmalloc(LZ4HC_MEM_COMPRESS);        
 23         if (!ctx)                                 
 24                 return ERR_PTR(-ENOMEM);          
 25                                                   
 26         return ctx;                               
 27 }                                                 
 28                                                   
 29 static int lz4hc_init(struct crypto_tfm *tfm)     
 30 {                                                 
 31         struct lz4hc_ctx *ctx = crypto_tfm_ctx    
 32                                                   
 33         ctx->lz4hc_comp_mem = lz4hc_alloc_ctx(    
 34         if (IS_ERR(ctx->lz4hc_comp_mem))          
 35                 return -ENOMEM;                   
 36                                                   
 37         return 0;                                 
 38 }                                                 
 39                                                   
 40 static void lz4hc_free_ctx(struct crypto_scomp    
 41 {                                                 
 42         vfree(ctx);                               
 43 }                                                 
 44                                                   
 45 static void lz4hc_exit(struct crypto_tfm *tfm)    
 46 {                                                 
 47         struct lz4hc_ctx *ctx = crypto_tfm_ctx    
 48                                                   
 49         lz4hc_free_ctx(NULL, ctx->lz4hc_comp_m    
 50 }                                                 
 51                                                   
 52 static int __lz4hc_compress_crypto(const u8 *s    
 53                                    u8 *dst, un    
 54 {                                                 
 55         int out_len = LZ4_compress_HC(src, dst    
 56                 *dlen, LZ4HC_DEFAULT_CLEVEL, c    
 57                                                   
 58         if (!out_len)                             
 59                 return -EINVAL;                   
 60                                                   
 61         *dlen = out_len;                          
 62         return 0;                                 
 63 }                                                 
 64                                                   
 65 static int lz4hc_scompress(struct crypto_scomp    
 66                            unsigned int slen,     
 67                            void *ctx)             
 68 {                                                 
 69         return __lz4hc_compress_crypto(src, sl    
 70 }                                                 
 71                                                   
 72 static int lz4hc_compress_crypto(struct crypto    
 73                                  unsigned int     
 74                                  unsigned int     
 75 {                                                 
 76         struct lz4hc_ctx *ctx = crypto_tfm_ctx    
 77                                                   
 78         return __lz4hc_compress_crypto(src, sl    
 79                                         ctx->l    
 80 }                                                 
 81                                                   
 82 static int __lz4hc_decompress_crypto(const u8     
 83                                      u8 *dst,     
 84 {                                                 
 85         int out_len = LZ4_decompress_safe(src,    
 86                                                   
 87         if (out_len < 0)                          
 88                 return -EINVAL;                   
 89                                                   
 90         *dlen = out_len;                          
 91         return 0;                                 
 92 }                                                 
 93                                                   
 94 static int lz4hc_sdecompress(struct crypto_sco    
 95                              unsigned int slen    
 96                              void *ctx)           
 97 {                                                 
 98         return __lz4hc_decompress_crypto(src,     
 99 }                                                 
100                                                   
101 static int lz4hc_decompress_crypto(struct cryp    
102                                    unsigned in    
103                                    unsigned in    
104 {                                                 
105         return __lz4hc_decompress_crypto(src,     
106 }                                                 
107                                                   
108 static struct crypto_alg alg_lz4hc = {            
109         .cra_name               = "lz4hc",        
110         .cra_driver_name        = "lz4hc-gener    
111         .cra_flags              = CRYPTO_ALG_T    
112         .cra_ctxsize            = sizeof(struc    
113         .cra_module             = THIS_MODULE,    
114         .cra_init               = lz4hc_init,     
115         .cra_exit               = lz4hc_exit,     
116         .cra_u                  = { .compress     
117         .coa_compress           = lz4hc_compre    
118         .coa_decompress         = lz4hc_decomp    
119 };                                                
120                                                   
121 static struct scomp_alg scomp = {                 
122         .alloc_ctx              = lz4hc_alloc_    
123         .free_ctx               = lz4hc_free_c    
124         .compress               = lz4hc_scompr    
125         .decompress             = lz4hc_sdecom    
126         .base                   = {               
127                 .cra_name       = "lz4hc",        
128                 .cra_driver_name = "lz4hc-scom    
129                 .cra_module      = THIS_MODULE    
130         }                                         
131 };                                                
132                                                   
133 static int __init lz4hc_mod_init(void)            
134 {                                                 
135         int ret;                                  
136                                                   
137         ret = crypto_register_alg(&alg_lz4hc);    
138         if (ret)                                  
139                 return ret;                       
140                                                   
141         ret = crypto_register_scomp(&scomp);      
142         if (ret) {                                
143                 crypto_unregister_alg(&alg_lz4    
144                 return ret;                       
145         }                                         
146                                                   
147         return ret;                               
148 }                                                 
149                                                   
150 static void __exit lz4hc_mod_fini(void)           
151 {                                                 
152         crypto_unregister_alg(&alg_lz4hc);        
153         crypto_unregister_scomp(&scomp);          
154 }                                                 
155                                                   
156 subsys_initcall(lz4hc_mod_init);                  
157 module_exit(lz4hc_mod_fini);                      
158                                                   
159 MODULE_LICENSE("GPL");                            
160 MODULE_DESCRIPTION("LZ4HC Compression Algorith    
161 MODULE_ALIAS_CRYPTO("lz4hc");                     
162                                                   

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