aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2014-04-24 14:05:12 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-05-08 09:58:06 -0400
commitfa9659cd4d3f40cead6263986cc235f3e67ab872 (patch)
treec052231b590336ebbc2cc068c1886ba51708021f
parent9f84951fc6f30eff20567632131c38725705753d (diff)
crypto: caam - Contain caam_jr_strstatus() ugliness
The tentacles of this function were firmly attached to various places in the CAAM code. Just cut them, or this cthulhu function will sprout them anew. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/caam/caamalg.c28
-rw-r--r--drivers/crypto/caam/caamhash.c28
-rw-r--r--drivers/crypto/caam/caamrng.c7
-rw-r--r--drivers/crypto/caam/error.c5
-rw-r--r--drivers/crypto/caam/error.h2
-rw-r--r--drivers/crypto/caam/key_gen.c7
6 files changed, 24 insertions, 53 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 5f891254db73..339277c7acb9 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -918,11 +918,8 @@ static void aead_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
918 edesc = (struct aead_edesc *)((char *)desc - 918 edesc = (struct aead_edesc *)((char *)desc -
919 offsetof(struct aead_edesc, hw_desc)); 919 offsetof(struct aead_edesc, hw_desc));
920 920
921 if (err) { 921 if (err)
922 char tmp[CAAM_ERROR_STR_MAX]; 922 caam_jr_strstatus(jrdev, err);
923
924 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
925 }
926 923
927 aead_unmap(jrdev, edesc, req); 924 aead_unmap(jrdev, edesc, req);
928 925
@@ -969,11 +966,8 @@ static void aead_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
969 req->cryptlen - ctx->authsize, 1); 966 req->cryptlen - ctx->authsize, 1);
970#endif 967#endif
971 968
972 if (err) { 969 if (err)
973 char tmp[CAAM_ERROR_STR_MAX]; 970 caam_jr_strstatus(jrdev, err);
974
975 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
976 }
977 971
978 aead_unmap(jrdev, edesc, req); 972 aead_unmap(jrdev, edesc, req);
979 973
@@ -1018,11 +1012,8 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
1018 edesc = (struct ablkcipher_edesc *)((char *)desc - 1012 edesc = (struct ablkcipher_edesc *)((char *)desc -
1019 offsetof(struct ablkcipher_edesc, hw_desc)); 1013 offsetof(struct ablkcipher_edesc, hw_desc));
1020 1014
1021 if (err) { 1015 if (err)
1022 char tmp[CAAM_ERROR_STR_MAX]; 1016 caam_jr_strstatus(jrdev, err);
1023
1024 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
1025 }
1026 1017
1027#ifdef DEBUG 1018#ifdef DEBUG
1028 print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", 1019 print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ",
@@ -1053,11 +1044,8 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
1053 1044
1054 edesc = (struct ablkcipher_edesc *)((char *)desc - 1045 edesc = (struct ablkcipher_edesc *)((char *)desc -
1055 offsetof(struct ablkcipher_edesc, hw_desc)); 1046 offsetof(struct ablkcipher_edesc, hw_desc));
1056 if (err) { 1047 if (err)
1057 char tmp[CAAM_ERROR_STR_MAX]; 1048 caam_jr_strstatus(jrdev, err);
1058
1059 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
1060 }
1061 1049
1062#ifdef DEBUG 1050#ifdef DEBUG
1063 print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ", 1051 print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ",
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 2d244e629ed2..0d9284ef96a8 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -633,11 +633,8 @@ static void ahash_done(struct device *jrdev, u32 *desc, u32 err,
633 633
634 edesc = (struct ahash_edesc *)((char *)desc - 634 edesc = (struct ahash_edesc *)((char *)desc -
635 offsetof(struct ahash_edesc, hw_desc)); 635 offsetof(struct ahash_edesc, hw_desc));
636 if (err) { 636 if (err)
637 char tmp[CAAM_ERROR_STR_MAX]; 637 caam_jr_strstatus(jrdev, err);
638
639 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
640 }
641 638
642 ahash_unmap(jrdev, edesc, req, digestsize); 639 ahash_unmap(jrdev, edesc, req, digestsize);
643 kfree(edesc); 640 kfree(edesc);
@@ -671,11 +668,8 @@ static void ahash_done_bi(struct device *jrdev, u32 *desc, u32 err,
671 668
672 edesc = (struct ahash_edesc *)((char *)desc - 669 edesc = (struct ahash_edesc *)((char *)desc -
673 offsetof(struct ahash_edesc, hw_desc)); 670 offsetof(struct ahash_edesc, hw_desc));
674 if (err) { 671 if (err)
675 char tmp[CAAM_ERROR_STR_MAX]; 672 caam_jr_strstatus(jrdev, err);
676
677 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
678 }
679 673
680 ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_BIDIRECTIONAL); 674 ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_BIDIRECTIONAL);
681 kfree(edesc); 675 kfree(edesc);
@@ -709,11 +703,8 @@ static void ahash_done_ctx_src(struct device *jrdev, u32 *desc, u32 err,
709 703
710 edesc = (struct ahash_edesc *)((char *)desc - 704 edesc = (struct ahash_edesc *)((char *)desc -
711 offsetof(struct ahash_edesc, hw_desc)); 705 offsetof(struct ahash_edesc, hw_desc));
712 if (err) { 706 if (err)
713 char tmp[CAAM_ERROR_STR_MAX]; 707 caam_jr_strstatus(jrdev, err);
714
715 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
716 }
717 708
718 ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE); 709 ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
719 kfree(edesc); 710 kfree(edesc);
@@ -747,11 +738,8 @@ static void ahash_done_ctx_dst(struct device *jrdev, u32 *desc, u32 err,
747 738
748 edesc = (struct ahash_edesc *)((char *)desc - 739 edesc = (struct ahash_edesc *)((char *)desc -
749 offsetof(struct ahash_edesc, hw_desc)); 740 offsetof(struct ahash_edesc, hw_desc));
750 if (err) { 741 if (err)
751 char tmp[CAAM_ERROR_STR_MAX]; 742 caam_jr_strstatus(jrdev, err);
752
753 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
754 }
755 743
756 ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_TO_DEVICE); 744 ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_TO_DEVICE);
757 kfree(edesc); 745 kfree(edesc);
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index 3529b54048c9..8c07d3153f12 100644
--- a/drivers/crypto/caam/caamrng.c
+++ b/drivers/crypto/caam/caamrng.c
@@ -103,11 +103,8 @@ static void rng_done(struct device *jrdev, u32 *desc, u32 err, void *context)
103 bd = (struct buf_data *)((char *)desc - 103 bd = (struct buf_data *)((char *)desc -
104 offsetof(struct buf_data, hw_desc)); 104 offsetof(struct buf_data, hw_desc));
105 105
106 if (err) { 106 if (err)
107 char tmp[CAAM_ERROR_STR_MAX]; 107 caam_jr_strstatus(jrdev, err);
108
109 dev_err(jrdev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
110 }
111 108
112 atomic_set(&bd->empty, BUF_NOT_EMPTY); 109 atomic_set(&bd->empty, BUF_NOT_EMPTY);
113 complete(&bd->filled); 110 complete(&bd->filled);
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 9f25f5296029..ba426d902783 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -243,8 +243,9 @@ static void report_cond_code_status(u32 status, char *outstr)
243 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__)); 243 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
244} 244}
245 245
246char *caam_jr_strstatus(char *outstr, u32 status) 246void caam_jr_strstatus(struct device *jrdev, u32 status)
247{ 247{
248 char outstr[CAAM_ERROR_STR_MAX];
248 static const struct stat_src { 249 static const struct stat_src {
249 void (*report_ssed)(u32 status, char *outstr); 250 void (*report_ssed)(u32 status, char *outstr);
250 char *error; 251 char *error;
@@ -265,6 +266,6 @@ char *caam_jr_strstatus(char *outstr, u32 status)
265 if (status_src[ssrc].report_ssed) 266 if (status_src[ssrc].report_ssed)
266 status_src[ssrc].report_ssed(status, outstr); 267 status_src[ssrc].report_ssed(status, outstr);
267 268
268 return outstr; 269 dev_err(jrdev, "%08x: %s\n", status, outstr);
269} 270}
270EXPORT_SYMBOL(caam_jr_strstatus); 271EXPORT_SYMBOL(caam_jr_strstatus);
diff --git a/drivers/crypto/caam/error.h b/drivers/crypto/caam/error.h
index 02c7baa1748e..b6350b0d9153 100644
--- a/drivers/crypto/caam/error.h
+++ b/drivers/crypto/caam/error.h
@@ -7,5 +7,5 @@
7#ifndef CAAM_ERROR_H 7#ifndef CAAM_ERROR_H
8#define CAAM_ERROR_H 8#define CAAM_ERROR_H
9#define CAAM_ERROR_STR_MAX 302 9#define CAAM_ERROR_STR_MAX 302
10extern char *caam_jr_strstatus(char *outstr, u32 status); 10void caam_jr_strstatus(struct device *jrdev, u32 status);
11#endif /* CAAM_ERROR_H */ 11#endif /* CAAM_ERROR_H */
diff --git a/drivers/crypto/caam/key_gen.c b/drivers/crypto/caam/key_gen.c
index ea2e406610eb..871703c49d2c 100644
--- a/drivers/crypto/caam/key_gen.c
+++ b/drivers/crypto/caam/key_gen.c
@@ -19,11 +19,8 @@ void split_key_done(struct device *dev, u32 *desc, u32 err,
19 dev_err(dev, "%s %d: err 0x%x\n", __func__, __LINE__, err); 19 dev_err(dev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
20#endif 20#endif
21 21
22 if (err) { 22 if (err)
23 char tmp[CAAM_ERROR_STR_MAX]; 23 caam_jr_strstatus(dev, err);
24
25 dev_err(dev, "%08x: %s\n", err, caam_jr_strstatus(tmp, err));
26 }
27 24
28 res->err = err; 25 res->err = err;
29 26