acompress.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Asynchronous Compression operations
  3. *
  4. * Copyright (c) 2016, Intel Corporation
  5. * Authors: Weigang Li <weigang.li@intel.com>
  6. * Giovanni Cabiddu <giovanni.cabiddu@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version.
  12. *
  13. */
  14. #ifndef _CRYPTO_ACOMP_INT_H
  15. #define _CRYPTO_ACOMP_INT_H
  16. #include <crypto/acompress.h>
  17. /*
  18. * Transform internal helpers.
  19. */
  20. static inline void *acomp_request_ctx(struct acomp_req *req)
  21. {
  22. return req->__ctx;
  23. }
  24. static inline void *acomp_tfm_ctx(struct crypto_acomp *tfm)
  25. {
  26. return tfm->base.__crt_ctx;
  27. }
  28. static inline void acomp_request_complete(struct acomp_req *req,
  29. int err)
  30. {
  31. req->base.complete(&req->base, err);
  32. }
  33. static inline const char *acomp_alg_name(struct crypto_acomp *tfm)
  34. {
  35. return crypto_acomp_tfm(tfm)->__crt_alg->cra_name;
  36. }
  37. static inline struct acomp_req *__acomp_request_alloc(struct crypto_acomp *tfm)
  38. {
  39. struct acomp_req *req;
  40. req = kzalloc(sizeof(*req) + crypto_acomp_reqsize(tfm), GFP_KERNEL);
  41. if (likely(req))
  42. acomp_request_set_tfm(req, tfm);
  43. return req;
  44. }
  45. static inline void __acomp_request_free(struct acomp_req *req)
  46. {
  47. kzfree(req);
  48. }
  49. /**
  50. * crypto_register_acomp() -- Register asynchronous compression algorithm
  51. *
  52. * Function registers an implementation of an asynchronous
  53. * compression algorithm
  54. *
  55. * @alg: algorithm definition
  56. *
  57. * Return: zero on success; error code in case of error
  58. */
  59. int crypto_register_acomp(struct acomp_alg *alg);
  60. /**
  61. * crypto_unregister_acomp() -- Unregister asynchronous compression algorithm
  62. *
  63. * Function unregisters an implementation of an asynchronous
  64. * compression algorithm
  65. *
  66. * @alg: algorithm definition
  67. *
  68. * Return: zero on success; error code in case of error
  69. */
  70. int crypto_unregister_acomp(struct acomp_alg *alg);
  71. int crypto_register_acomps(struct acomp_alg *algs, int count);
  72. void crypto_unregister_acomps(struct acomp_alg *algs, int count);
  73. #endif