drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / drivers / block / zram / backend_842.c
blob10d9d5c60f53136d8eba257188ab27747ab855f2
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/kernel.h>
4 #include <linux/slab.h>
5 #include <linux/sw842.h>
6 #include <linux/vmalloc.h>
8 #include "backend_842.h"
10 static void release_params_842(struct zcomp_params *params)
14 static int setup_params_842(struct zcomp_params *params)
16 return 0;
19 static void destroy_842(struct zcomp_ctx *ctx)
21 kfree(ctx->context);
24 static int create_842(struct zcomp_params *params, struct zcomp_ctx *ctx)
26 ctx->context = kmalloc(SW842_MEM_COMPRESS, GFP_KERNEL);
27 if (!ctx->context)
28 return -ENOMEM;
29 return 0;
32 static int compress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
33 struct zcomp_req *req)
35 unsigned int dlen = req->dst_len;
36 int ret;
38 ret = sw842_compress(req->src, req->src_len, req->dst, &dlen,
39 ctx->context);
40 if (ret == 0)
41 req->dst_len = dlen;
42 return ret;
45 static int decompress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
46 struct zcomp_req *req)
48 unsigned int dlen = req->dst_len;
50 return sw842_decompress(req->src, req->src_len, req->dst, &dlen);
53 const struct zcomp_ops backend_842 = {
54 .compress = compress_842,
55 .decompress = decompress_842,
56 .create_ctx = create_842,
57 .destroy_ctx = destroy_842,
58 .setup_params = setup_params_842,
59 .release_params = release_params_842,
60 .name = "842",