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