@@ -24,19 +24,23 @@ static void zstd_destroy(void *ctx)
2424 kfree (zctx );
2525}
2626
27- static void * zstd_create (void )
27+ static void * zstd_create (struct zcomp_params * params )
2828{
29- zstd_parameters params ;
29+ zstd_parameters prm ;
3030 struct zstd_ctx * ctx ;
3131 size_t sz ;
3232
3333 ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
3434 if (!ctx )
3535 return NULL ;
3636
37- ctx -> level = zstd_default_clevel ();
38- params = zstd_get_params (ctx -> level , PAGE_SIZE );
39- sz = zstd_cctx_workspace_bound (& params .cParams );
37+ if (params -> level != ZCOMP_PARAM_NO_LEVEL )
38+ ctx -> level = params -> level ;
39+ else
40+ ctx -> level = zstd_default_clevel ();
41+
42+ prm = zstd_get_params (ctx -> level , PAGE_SIZE );
43+ sz = zstd_cctx_workspace_bound (& prm .cParams );
4044 ctx -> cctx_mem = vzalloc (sz );
4145 if (!ctx -> cctx_mem )
4246 goto error ;
@@ -65,11 +69,11 @@ static int zstd_compress(void *ctx, const unsigned char *src, size_t src_len,
6569 unsigned char * dst , size_t * dst_len )
6670{
6771 struct zstd_ctx * zctx = ctx ;
68- const zstd_parameters params = zstd_get_params (zctx -> level , PAGE_SIZE );
72+ const zstd_parameters prm = zstd_get_params (zctx -> level , PAGE_SIZE );
6973 size_t ret ;
7074
7175 ret = zstd_compress_cctx (zctx -> cctx , dst , * dst_len ,
72- src , src_len , & params );
76+ src , src_len , & prm );
7377 if (zstd_is_error (ret ))
7478 return - EINVAL ;
7579 * dst_len = ret ;
0 commit comments