Lines Matching refs:ctx

32 static int zstd_comp_init(struct zstd_ctx *ctx)
38 ctx->cwksp = vzalloc(wksp_size);
39 if (!ctx->cwksp) {
44 ctx->cctx = zstd_init_cctx(ctx->cwksp, wksp_size);
45 if (!ctx->cctx) {
52 vfree(ctx->cwksp);
56 static int zstd_decomp_init(struct zstd_ctx *ctx)
61 ctx->dwksp = vzalloc(wksp_size);
62 if (!ctx->dwksp) {
67 ctx->dctx = zstd_init_dctx(ctx->dwksp, wksp_size);
68 if (!ctx->dctx) {
75 vfree(ctx->dwksp);
79 static void zstd_comp_exit(struct zstd_ctx *ctx)
81 vfree(ctx->cwksp);
82 ctx->cwksp = NULL;
83 ctx->cctx = NULL;
86 static void zstd_decomp_exit(struct zstd_ctx *ctx)
88 vfree(ctx->dwksp);
89 ctx->dwksp = NULL;
90 ctx->dctx = NULL;
93 static int __zstd_init(void *ctx)
97 ret = zstd_comp_init(ctx);
100 ret = zstd_decomp_init(ctx);
102 zstd_comp_exit(ctx);
109 struct zstd_ctx *ctx;
111 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
112 if (!ctx)
115 ret = __zstd_init(ctx);
117 kfree(ctx);
121 return ctx;
126 struct zstd_ctx *ctx = crypto_tfm_ctx(tfm);
128 return __zstd_init(ctx);
131 static void __zstd_exit(void *ctx)
133 zstd_comp_exit(ctx);
134 zstd_decomp_exit(ctx);
137 static void zstd_free_ctx(struct crypto_scomp *tfm, void *ctx)
139 __zstd_exit(ctx);
140 kfree_sensitive(ctx);
145 struct zstd_ctx *ctx = crypto_tfm_ctx(tfm);
147 __zstd_exit(ctx);
151 u8 *dst, unsigned int *dlen, void *ctx)
154 struct zstd_ctx *zctx = ctx;
167 struct zstd_ctx *ctx = crypto_tfm_ctx(tfm);
169 return __zstd_compress(src, slen, dst, dlen, ctx);
174 void *ctx)
176 return __zstd_compress(src, slen, dst, dlen, ctx);
180 u8 *dst, unsigned int *dlen, void *ctx)
183 struct zstd_ctx *zctx = ctx;
195 struct zstd_ctx *ctx = crypto_tfm_ctx(tfm);
197 return __zstd_decompress(src, slen, dst, dlen, ctx);
202 void *ctx)
204 return __zstd_decompress(src, slen, dst, dlen, ctx);