Revert "tty: hvc: Fix data abort due to race in hvc_open"
[linux/fpc-iii.git] / include / crypto / internal / scompress.h
blobf834274c2493fa9d16d82cc4bf9150f412b61e6f
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Synchronous Compression operations
5 * Copyright 2015 LG Electronics Inc.
6 * Copyright (c) 2016, Intel Corporation
7 * Author: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
8 */
9 #ifndef _CRYPTO_SCOMP_INT_H
10 #define _CRYPTO_SCOMP_INT_H
11 #include <linux/crypto.h>
13 #define SCOMP_SCRATCH_SIZE 131072
15 struct crypto_scomp {
16 struct crypto_tfm base;
19 /**
20 * struct scomp_alg - synchronous compression algorithm
22 * @alloc_ctx: Function allocates algorithm specific context
23 * @free_ctx: Function frees context allocated with alloc_ctx
24 * @compress: Function performs a compress operation
25 * @decompress: Function performs a de-compress operation
26 * @base: Common crypto API algorithm data structure
28 struct scomp_alg {
29 void *(*alloc_ctx)(struct crypto_scomp *tfm);
30 void (*free_ctx)(struct crypto_scomp *tfm, void *ctx);
31 int (*compress)(struct crypto_scomp *tfm, const u8 *src,
32 unsigned int slen, u8 *dst, unsigned int *dlen,
33 void *ctx);
34 int (*decompress)(struct crypto_scomp *tfm, const u8 *src,
35 unsigned int slen, u8 *dst, unsigned int *dlen,
36 void *ctx);
37 struct crypto_alg base;
40 static inline struct scomp_alg *__crypto_scomp_alg(struct crypto_alg *alg)
42 return container_of(alg, struct scomp_alg, base);
45 static inline struct crypto_scomp *__crypto_scomp_tfm(struct crypto_tfm *tfm)
47 return container_of(tfm, struct crypto_scomp, base);
50 static inline struct crypto_tfm *crypto_scomp_tfm(struct crypto_scomp *tfm)
52 return &tfm->base;
55 static inline void crypto_free_scomp(struct crypto_scomp *tfm)
57 crypto_destroy_tfm(tfm, crypto_scomp_tfm(tfm));
60 static inline struct scomp_alg *crypto_scomp_alg(struct crypto_scomp *tfm)
62 return __crypto_scomp_alg(crypto_scomp_tfm(tfm)->__crt_alg);
65 static inline void *crypto_scomp_alloc_ctx(struct crypto_scomp *tfm)
67 return crypto_scomp_alg(tfm)->alloc_ctx(tfm);
70 static inline void crypto_scomp_free_ctx(struct crypto_scomp *tfm,
71 void *ctx)
73 return crypto_scomp_alg(tfm)->free_ctx(tfm, ctx);
76 static inline int crypto_scomp_compress(struct crypto_scomp *tfm,
77 const u8 *src, unsigned int slen,
78 u8 *dst, unsigned int *dlen, void *ctx)
80 return crypto_scomp_alg(tfm)->compress(tfm, src, slen, dst, dlen, ctx);
83 static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
84 const u8 *src, unsigned int slen,
85 u8 *dst, unsigned int *dlen,
86 void *ctx)
88 return crypto_scomp_alg(tfm)->decompress(tfm, src, slen, dst, dlen,
89 ctx);
92 int crypto_init_scomp_ops_async(struct crypto_tfm *tfm);
93 struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req);
94 void crypto_acomp_scomp_free_ctx(struct acomp_req *req);
96 /**
97 * crypto_register_scomp() -- Register synchronous compression algorithm
99 * Function registers an implementation of a synchronous
100 * compression algorithm
102 * @alg: algorithm definition
104 * Return: zero on success; error code in case of error
106 int crypto_register_scomp(struct scomp_alg *alg);
109 * crypto_unregister_scomp() -- Unregister synchronous compression algorithm
111 * Function unregisters an implementation of a synchronous
112 * compression algorithm
114 * @alg: algorithm definition
116 void crypto_unregister_scomp(struct scomp_alg *alg);
118 int crypto_register_scomps(struct scomp_alg *algs, int count);
119 void crypto_unregister_scomps(struct scomp_alg *algs, int count);
121 #endif