Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Asynchronous Compression operations
0004  *
0005  * Copyright (c) 2016, Intel Corporation
0006  * Authors: Weigang Li <weigang.li@intel.com>
0007  *          Giovanni Cabiddu <giovanni.cabiddu@intel.com>
0008  */
0009 #ifndef _CRYPTO_ACOMP_INT_H
0010 #define _CRYPTO_ACOMP_INT_H
0011 #include <crypto/acompress.h>
0012 
0013 /*
0014  * Transform internal helpers.
0015  */
0016 static inline void *acomp_request_ctx(struct acomp_req *req)
0017 {
0018     return req->__ctx;
0019 }
0020 
0021 static inline void *acomp_tfm_ctx(struct crypto_acomp *tfm)
0022 {
0023     return tfm->base.__crt_ctx;
0024 }
0025 
0026 static inline void acomp_request_complete(struct acomp_req *req,
0027                       int err)
0028 {
0029     req->base.complete(&req->base, err);
0030 }
0031 
0032 static inline const char *acomp_alg_name(struct crypto_acomp *tfm)
0033 {
0034     return crypto_acomp_tfm(tfm)->__crt_alg->cra_name;
0035 }
0036 
0037 static inline struct acomp_req *__acomp_request_alloc(struct crypto_acomp *tfm)
0038 {
0039     struct acomp_req *req;
0040 
0041     req = kzalloc(sizeof(*req) + crypto_acomp_reqsize(tfm), GFP_KERNEL);
0042     if (likely(req))
0043         acomp_request_set_tfm(req, tfm);
0044     return req;
0045 }
0046 
0047 static inline void __acomp_request_free(struct acomp_req *req)
0048 {
0049     kfree_sensitive(req);
0050 }
0051 
0052 /**
0053  * crypto_register_acomp() -- Register asynchronous compression algorithm
0054  *
0055  * Function registers an implementation of an asynchronous
0056  * compression algorithm
0057  *
0058  * @alg:    algorithm definition
0059  *
0060  * Return:  zero on success; error code in case of error
0061  */
0062 int crypto_register_acomp(struct acomp_alg *alg);
0063 
0064 /**
0065  * crypto_unregister_acomp() -- Unregister asynchronous compression algorithm
0066  *
0067  * Function unregisters an implementation of an asynchronous
0068  * compression algorithm
0069  *
0070  * @alg:    algorithm definition
0071  */
0072 void crypto_unregister_acomp(struct acomp_alg *alg);
0073 
0074 int crypto_register_acomps(struct acomp_alg *algs, int count);
0075 void crypto_unregister_acomps(struct acomp_alg *algs, int count);
0076 
0077 #endif