]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/block/zram/zcomp_lz4.c
Merge tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[mirror_ubuntu-bionic-kernel.git] / drivers / block / zram / zcomp_lz4.c
1 /*
2 * Copyright (C) 2014 Sergey Senozhatsky.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10 #include <linux/kernel.h>
11 #include <linux/slab.h>
12 #include <linux/lz4.h>
13
14 #include "zcomp_lz4.h"
15
16 static void *zcomp_lz4_create(void)
17 {
18 return kzalloc(LZ4_MEM_COMPRESS, GFP_KERNEL);
19 }
20
21 static void zcomp_lz4_destroy(void *private)
22 {
23 kfree(private);
24 }
25
26 static int zcomp_lz4_compress(const unsigned char *src, unsigned char *dst,
27 size_t *dst_len, void *private)
28 {
29 /* return : Success if return 0 */
30 return lz4_compress(src, PAGE_SIZE, dst, dst_len, private);
31 }
32
33 static int zcomp_lz4_decompress(const unsigned char *src, size_t src_len,
34 unsigned char *dst)
35 {
36 size_t dst_len = PAGE_SIZE;
37 /* return : Success if return 0 */
38 return lz4_decompress_unknownoutputsize(src, src_len, dst, &dst_len);
39 }
40
41 struct zcomp_backend zcomp_lz4 = {
42 .compress = zcomp_lz4_compress,
43 .decompress = zcomp_lz4_decompress,
44 .create = zcomp_lz4_create,
45 .destroy = zcomp_lz4_destroy,
46 .name = "lz4",
47 };