18
18
* drivers/crypto/nx/nx-842-crypto.c
19
19
*/
20
20
21
+ #include <crypto/internal/scompress.h>
21
22
#include <linux/init.h>
22
23
#include <linux/module.h>
23
- #include <linux/crypto.h>
24
24
#include <linux/sw842.h>
25
- #include <crypto/internal/scompress.h>
26
25
27
26
struct crypto842_ctx {
28
27
void * wmem ; /* working memory for compress */
@@ -39,73 +38,25 @@ static void *crypto842_alloc_ctx(void)
39
38
return ctx ;
40
39
}
41
40
42
- static int crypto842_init (struct crypto_tfm * tfm )
43
- {
44
- struct crypto842_ctx * ctx = crypto_tfm_ctx (tfm );
45
-
46
- ctx -> wmem = crypto842_alloc_ctx ();
47
- if (IS_ERR (ctx -> wmem ))
48
- return - ENOMEM ;
49
-
50
- return 0 ;
51
- }
52
-
53
41
static void crypto842_free_ctx (void * ctx )
54
42
{
55
43
kfree (ctx );
56
44
}
57
45
58
- static void crypto842_exit (struct crypto_tfm * tfm )
59
- {
60
- struct crypto842_ctx * ctx = crypto_tfm_ctx (tfm );
61
-
62
- crypto842_free_ctx (ctx -> wmem );
63
- }
64
-
65
- static int crypto842_compress (struct crypto_tfm * tfm ,
66
- const u8 * src , unsigned int slen ,
67
- u8 * dst , unsigned int * dlen )
68
- {
69
- struct crypto842_ctx * ctx = crypto_tfm_ctx (tfm );
70
-
71
- return sw842_compress (src , slen , dst , dlen , ctx -> wmem );
72
- }
73
-
74
46
static int crypto842_scompress (struct crypto_scomp * tfm ,
75
47
const u8 * src , unsigned int slen ,
76
48
u8 * dst , unsigned int * dlen , void * ctx )
77
49
{
78
50
return sw842_compress (src , slen , dst , dlen , ctx );
79
51
}
80
52
81
- static int crypto842_decompress (struct crypto_tfm * tfm ,
82
- const u8 * src , unsigned int slen ,
83
- u8 * dst , unsigned int * dlen )
84
- {
85
- return sw842_decompress (src , slen , dst , dlen );
86
- }
87
-
88
53
static int crypto842_sdecompress (struct crypto_scomp * tfm ,
89
54
const u8 * src , unsigned int slen ,
90
55
u8 * dst , unsigned int * dlen , void * ctx )
91
56
{
92
57
return sw842_decompress (src , slen , dst , dlen );
93
58
}
94
59
95
- static struct crypto_alg alg = {
96
- .cra_name = "842" ,
97
- .cra_driver_name = "842-generic" ,
98
- .cra_priority = 100 ,
99
- .cra_flags = CRYPTO_ALG_TYPE_COMPRESS ,
100
- .cra_ctxsize = sizeof (struct crypto842_ctx ),
101
- .cra_module = THIS_MODULE ,
102
- .cra_init = crypto842_init ,
103
- .cra_exit = crypto842_exit ,
104
- .cra_u = { .compress = {
105
- .coa_compress = crypto842_compress ,
106
- .coa_decompress = crypto842_decompress } }
107
- };
108
-
109
60
static struct scomp_alg scomp = {
110
61
.alloc_ctx = crypto842_alloc_ctx ,
111
62
.free_ctx = crypto842_free_ctx ,
@@ -121,25 +72,12 @@ static struct scomp_alg scomp = {
121
72
122
73
static int __init crypto842_mod_init (void )
123
74
{
124
- int ret ;
125
-
126
- ret = crypto_register_alg (& alg );
127
- if (ret )
128
- return ret ;
129
-
130
- ret = crypto_register_scomp (& scomp );
131
- if (ret ) {
132
- crypto_unregister_alg (& alg );
133
- return ret ;
134
- }
135
-
136
- return ret ;
75
+ return crypto_register_scomp (& scomp );
137
76
}
138
77
subsys_initcall (crypto842_mod_init );
139
78
140
79
static void __exit crypto842_mod_exit (void )
141
80
{
142
- crypto_unregister_alg (& alg );
143
81
crypto_unregister_scomp (& scomp );
144
82
}
145
83
module_exit (crypto842_mod_exit );
0 commit comments