1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/kernel.h>
4 #include <linux/slab.h>
7 #include "backend_lzorle.h"
9 static void lzorle_release_params(struct zcomp_params
*params
)
13 static int lzorle_setup_params(struct zcomp_params
*params
)
18 static int lzorle_create(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
)
20 ctx
->context
= kzalloc(LZO1X_MEM_COMPRESS
, GFP_KERNEL
);
26 static void lzorle_destroy(struct zcomp_ctx
*ctx
)
31 static int lzorle_compress(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
,
32 struct zcomp_req
*req
)
36 ret
= lzorle1x_1_compress(req
->src
, req
->src_len
, req
->dst
,
37 &req
->dst_len
, ctx
->context
);
38 return ret
== LZO_E_OK
? 0 : ret
;
41 static int lzorle_decompress(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
,
42 struct zcomp_req
*req
)
46 ret
= lzo1x_decompress_safe(req
->src
, req
->src_len
,
47 req
->dst
, &req
->dst_len
);
48 return ret
== LZO_E_OK
? 0 : ret
;
51 const struct zcomp_ops backend_lzorle
= {
52 .compress
= lzorle_compress
,
53 .decompress
= lzorle_decompress
,
54 .create_ctx
= lzorle_create
,
55 .destroy_ctx
= lzorle_destroy
,
56 .setup_params
= lzorle_setup_params
,
57 .release_params
= lzorle_release_params
,