Skip to content

Commit 972b812

Browse files
horiagherbertx
authored andcommitted
crypto: caam/qi - fix compilation with DEBUG enabled
caam/qi driver does not compile when DEBUG is enabled (CRYPTO_DEV_FSL_CAAM_DEBUG=y): drivers/crypto/caam/caamalg_qi.c: In function 'ablkcipher_done': drivers/crypto/caam/caamalg_qi.c:794:2: error: implicit declaration of function 'dbg_dump_sg' [-Werror=implicit-function-declaration] dbg_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ", Since dbg_dump_sg() is shared between caam/jr and caam/qi, move it in a shared location and export it. At the same time: -reduce ifdeferry by providing a no-op implementation for !DEBUG case -rename it to caam_dump_sg() to be consistent in terms of exported symbols namespace (caam_*) Cc: <[email protected]> Fixes: b189817 ("crypto: caam/qi - add ablkcipher and authenc algorithms") Signed-off-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 84ea954 commit 972b812

File tree

4 files changed

+62
-54
lines changed

4 files changed

+62
-54
lines changed

drivers/crypto/caam/caamalg.c

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,6 @@
8181
#define debug(format, arg...)
8282
#endif
8383

84-
#ifdef DEBUG
85-
#include <linux/highmem.h>
86-
87-
static void dbg_dump_sg(const char *level, const char *prefix_str,
88-
int prefix_type, int rowsize, int groupsize,
89-
struct scatterlist *sg, size_t tlen, bool ascii)
90-
{
91-
struct scatterlist *it;
92-
void *it_page;
93-
size_t len;
94-
void *buf;
95-
96-
for (it = sg; it != NULL && tlen > 0 ; it = sg_next(sg)) {
97-
/*
98-
* make sure the scatterlist's page
99-
* has a valid virtual memory mapping
100-
*/
101-
it_page = kmap_atomic(sg_page(it));
102-
if (unlikely(!it_page)) {
103-
printk(KERN_ERR "dbg_dump_sg: kmap failed\n");
104-
return;
105-
}
106-
107-
buf = it_page + it->offset;
108-
len = min_t(size_t, tlen, it->length);
109-
print_hex_dump(level, prefix_str, prefix_type, rowsize,
110-
groupsize, buf, len, ascii);
111-
tlen -= len;
112-
113-
kunmap_atomic(it_page);
114-
}
115-
}
116-
#endif
117-
11884
static struct list_head alg_list;
11985

12086
struct caam_alg_entry {
@@ -898,10 +864,10 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
898864
print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ",
899865
DUMP_PREFIX_ADDRESS, 16, 4, req->info,
900866
edesc->src_nents > 1 ? 100 : ivsize, 1);
901-
dbg_dump_sg(KERN_ERR, "dst @"__stringify(__LINE__)": ",
902-
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
903-
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
904867
#endif
868+
caam_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ",
869+
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
870+
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
905871

906872
ablkcipher_unmap(jrdev, edesc, req);
907873

@@ -937,10 +903,10 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
937903
print_hex_dump(KERN_ERR, "dstiv @"__stringify(__LINE__)": ",
938904
DUMP_PREFIX_ADDRESS, 16, 4, req->info,
939905
ivsize, 1);
940-
dbg_dump_sg(KERN_ERR, "dst @"__stringify(__LINE__)": ",
941-
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
942-
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
943906
#endif
907+
caam_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ",
908+
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
909+
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
944910

945911
ablkcipher_unmap(jrdev, edesc, req);
946912

@@ -1107,10 +1073,10 @@ static void init_ablkcipher_job(u32 *sh_desc, dma_addr_t ptr,
11071073
ivsize, 1);
11081074
pr_err("asked=%d, nbytes%d\n",
11091075
(int)edesc->src_nents > 1 ? 100 : req->nbytes, req->nbytes);
1110-
dbg_dump_sg(KERN_ERR, "src @"__stringify(__LINE__)": ",
1111-
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1112-
edesc->src_nents > 1 ? 100 : req->nbytes, 1);
11131076
#endif
1077+
caam_dump_sg(KERN_ERR, "src @" __stringify(__LINE__)": ",
1078+
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1079+
edesc->src_nents > 1 ? 100 : req->nbytes, 1);
11141080

11151081
len = desc_len(sh_desc);
11161082
init_job_desc_shared(desc, ptr, len, HDR_SHARE_DEFER | HDR_REVERSE);
@@ -1164,10 +1130,10 @@ static void init_ablkcipher_giv_job(u32 *sh_desc, dma_addr_t ptr,
11641130
print_hex_dump(KERN_ERR, "presciv@" __stringify(__LINE__) ": ",
11651131
DUMP_PREFIX_ADDRESS, 16, 4, req->info,
11661132
ivsize, 1);
1167-
dbg_dump_sg(KERN_ERR, "src @" __stringify(__LINE__) ": ",
1168-
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1169-
edesc->src_nents > 1 ? 100 : req->nbytes, 1);
11701133
#endif
1134+
caam_dump_sg(KERN_ERR, "src @" __stringify(__LINE__) ": ",
1135+
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1136+
edesc->src_nents > 1 ? 100 : req->nbytes, 1);
11711137

11721138
len = desc_len(sh_desc);
11731139
init_job_desc_shared(desc, ptr, len, HDR_SHARE_DEFER | HDR_REVERSE);
@@ -1449,11 +1415,9 @@ static int aead_decrypt(struct aead_request *req)
14491415
u32 *desc;
14501416
int ret = 0;
14511417

1452-
#ifdef DEBUG
1453-
dbg_dump_sg(KERN_ERR, "dec src@"__stringify(__LINE__)": ",
1454-
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1455-
req->assoclen + req->cryptlen, 1);
1456-
#endif
1418+
caam_dump_sg(KERN_ERR, "dec src@" __stringify(__LINE__)": ",
1419+
DUMP_PREFIX_ADDRESS, 16, 4, req->src,
1420+
req->assoclen + req->cryptlen, 1);
14571421

14581422
/* allocate extended descriptor */
14591423
edesc = aead_edesc_alloc(req, AUTHENC_DESC_JOB_IO_LEN,

drivers/crypto/caam/caamalg_qi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
791791
print_hex_dump(KERN_ERR, "dstiv @" __stringify(__LINE__)": ",
792792
DUMP_PREFIX_ADDRESS, 16, 4, req->info,
793793
edesc->src_nents > 1 ? 100 : ivsize, 1);
794-
dbg_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ",
795-
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
796-
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
794+
caam_dump_sg(KERN_ERR, "dst @" __stringify(__LINE__)": ",
795+
DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
796+
edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
797797
#endif
798798

799799
ablkcipher_unmap(qidev, edesc, req);

drivers/crypto/caam/error.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,46 @@
99
#include "desc.h"
1010
#include "error.h"
1111

12+
#ifdef DEBUG
13+
#include <linux/highmem.h>
14+
15+
void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
16+
int rowsize, int groupsize, struct scatterlist *sg,
17+
size_t tlen, bool ascii)
18+
{
19+
struct scatterlist *it;
20+
void *it_page;
21+
size_t len;
22+
void *buf;
23+
24+
for (it = sg; it && tlen > 0 ; it = sg_next(sg)) {
25+
/*
26+
* make sure the scatterlist's page
27+
* has a valid virtual memory mapping
28+
*/
29+
it_page = kmap_atomic(sg_page(it));
30+
if (unlikely(!it_page)) {
31+
pr_err("caam_dump_sg: kmap failed\n");
32+
return;
33+
}
34+
35+
buf = it_page + it->offset;
36+
len = min_t(size_t, tlen, it->length);
37+
print_hex_dump(level, prefix_str, prefix_type, rowsize,
38+
groupsize, buf, len, ascii);
39+
tlen -= len;
40+
41+
kunmap_atomic(it_page);
42+
}
43+
}
44+
#else
45+
void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
46+
int rowsize, int groupsize, struct scatterlist *sg,
47+
size_t tlen, bool ascii)
48+
{}
49+
#endif /* DEBUG */
50+
EXPORT_SYMBOL(caam_dump_sg);
51+
1252
static const struct {
1353
u8 value;
1454
const char *error_text;

drivers/crypto/caam/error.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
#define CAAM_ERROR_H
99
#define CAAM_ERROR_STR_MAX 302
1010
void caam_jr_strstatus(struct device *jrdev, u32 status);
11+
12+
void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
13+
int rowsize, int groupsize, struct scatterlist *sg,
14+
size_t tlen, bool ascii);
1115
#endif /* CAAM_ERROR_H */

0 commit comments

Comments
 (0)