]> git.ipfire.org Git - people/ms/linux.git/blame - crypto/842.c
Merge tag 'pci-v4.4-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
[people/ms/linux.git] / crypto / 842.c
CommitLineData
35a1fc18 1/*
2062c5b6 2 * Cryptographic API for the 842 software compression algorithm.
35a1fc18
SJ
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
2062c5b6 14 * Copyright (C) IBM Corporation, 2011-2015
35a1fc18 15 *
2062c5b6
DS
16 * Original Authors: Robert Jennings <rcj@linux.vnet.ibm.com>
17 * Seth Jennings <sjenning@linux.vnet.ibm.com>
35a1fc18 18 *
2062c5b6
DS
19 * Rewrite: Dan Streetman <ddstreet@ieee.org>
20 *
21 * This is the software implementation of compression and decompression using
22 * the 842 format. This uses the software 842 library at lib/842/ which is
23 * only a reference implementation, and is very, very slow as compared to other
24 * software compressors. You probably do not want to use this software
25 * compression. If you have access to the PowerPC 842 compression hardware, you
26 * want to use the 842 hardware compression interface, which is at:
27 * drivers/crypto/nx/nx-842-crypto.c
35a1fc18
SJ
28 */
29
30#include <linux/init.h>
31#include <linux/module.h>
32#include <linux/crypto.h>
2062c5b6 33#include <linux/sw842.h>
35a1fc18 34
2062c5b6
DS
35struct crypto842_ctx {
36 char wmem[SW842_MEM_COMPRESS]; /* working memory for compress */
35a1fc18
SJ
37};
38
2062c5b6
DS
39static int crypto842_compress(struct crypto_tfm *tfm,
40 const u8 *src, unsigned int slen,
41 u8 *dst, unsigned int *dlen)
35a1fc18 42{
2062c5b6 43 struct crypto842_ctx *ctx = crypto_tfm_ctx(tfm);
35a1fc18 44
2062c5b6 45 return sw842_compress(src, slen, dst, dlen, ctx->wmem);
35a1fc18
SJ
46}
47
2062c5b6
DS
48static int crypto842_decompress(struct crypto_tfm *tfm,
49 const u8 *src, unsigned int slen,
50 u8 *dst, unsigned int *dlen)
35a1fc18 51{
2062c5b6 52 return sw842_decompress(src, slen, dst, dlen);
35a1fc18
SJ
53}
54
55static struct crypto_alg alg = {
56 .cra_name = "842",
2062c5b6
DS
57 .cra_driver_name = "842-generic",
58 .cra_priority = 100,
35a1fc18 59 .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
2062c5b6 60 .cra_ctxsize = sizeof(struct crypto842_ctx),
35a1fc18 61 .cra_module = THIS_MODULE,
35a1fc18 62 .cra_u = { .compress = {
2062c5b6
DS
63 .coa_compress = crypto842_compress,
64 .coa_decompress = crypto842_decompress } }
35a1fc18
SJ
65};
66
2062c5b6 67static int __init crypto842_mod_init(void)
35a1fc18 68{
35a1fc18
SJ
69 return crypto_register_alg(&alg);
70}
2062c5b6 71module_init(crypto842_mod_init);
35a1fc18 72
2062c5b6 73static void __exit crypto842_mod_exit(void)
35a1fc18
SJ
74{
75 crypto_unregister_alg(&alg);
76}
2062c5b6 77module_exit(crypto842_mod_exit);
35a1fc18
SJ
78
79MODULE_LICENSE("GPL");
2062c5b6 80MODULE_DESCRIPTION("842 Software Compression Algorithm");
5d26a105 81MODULE_ALIAS_CRYPTO("842");
2062c5b6
DS
82MODULE_ALIAS_CRYPTO("842-generic");
83MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");