ar71xx: fix build error
[openwrt.git] / target / linux / mxs / patches-4.4 / 110-crypto-mxsdcp-provide-importexport.patch
1 From: Fabio Estevam <fabio.estevam@nxp.com>
2
3 Currently the mxs-dcp driver fails to probe:
4
5 mxs-dcp 80028000.dcp: Failed to register sha1 hash!
6 mxs-dcp: probe of 80028000.dcp failed with error -22
7
8 This happens since commit 8996eafdcbad ("crypto: ahash - ensure statesize
9 is non-zero"), which requires statesize to be filled.
10
11 Other than filling statesize, we also need to provide the import/export
12 functions.
13
14 Based on the implementation of the sahara and caam drivers.
15
16 Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
17 ---
18 Changes since v2:
19 - Newly introduced in this series
20
21  drivers/crypto/mxs-dcp.c | 24 ++++++++++++++++++++++++
22  1 file changed, 24 insertions(+)
23
24 --- a/drivers/crypto/mxs-dcp.c
25 +++ b/drivers/crypto/mxs-dcp.c
26 @@ -775,6 +775,24 @@ static void dcp_sha_cra_exit(struct cryp
27  {
28  }
29  
30 +static int dcp_sha_export(struct ahash_request *req, void *out)
31 +{
32 +       struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
33 +
34 +       memcpy(out, rctx, sizeof(struct dcp_sha_req_ctx));
35 +
36 +       return 0;
37 +}
38 +
39 +static int dcp_sha_import(struct ahash_request *req, const void *in)
40 +{
41 +       struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
42 +
43 +       memcpy(rctx, in, sizeof(struct dcp_sha_req_ctx));
44 +
45 +       return 0;
46 +}
47 +
48  /* AES 128 ECB and AES 128 CBC */
49  static struct crypto_alg dcp_aes_algs[] = {
50         {
51 @@ -834,8 +852,11 @@ static struct ahash_alg dcp_sha1_alg = {
52         .final  = dcp_sha_final,
53         .finup  = dcp_sha_finup,
54         .digest = dcp_sha_digest,
55 +       .import = dcp_sha_import,
56 +       .export = dcp_sha_export,
57         .halg   = {
58                 .digestsize     = SHA1_DIGEST_SIZE,
59 +               .statesize      = sizeof(struct dcp_sha_req_ctx),
60                 .base           = {
61                         .cra_name               = "sha1",
62                         .cra_driver_name        = "sha1-dcp",
63 @@ -858,8 +879,11 @@ static struct ahash_alg dcp_sha256_alg =
64         .final  = dcp_sha_final,
65         .finup  = dcp_sha_finup,
66         .digest = dcp_sha_digest,
67 +       .import = dcp_sha_import,
68 +       .export = dcp_sha_export,
69         .halg   = {
70                 .digestsize     = SHA256_DIGEST_SIZE,
71 +               .statesize      = sizeof(struct dcp_sha_req_ctx),
72                 .base           = {
73                         .cra_name               = "sha256",
74                         .cra_driver_name        = "sha256-dcp",