crypto: caam/qi - fix compilation with DEBUG enabled
authorHoria Geantă <horia.geanta@nxp.com>
Mon, 10 Jul 2017 05:40:28 +0000 (08:40 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 18 Jul 2017 10:16:00 +0000 (18:16 +0800)
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: <stable@vger.kernel.org>
Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/caamalg_qi.c
drivers/crypto/caam/error.c
drivers/crypto/caam/error.h

index 0488b7f81dcf314ae0b9c37acf8ffd65efeb1c29..54f3b375a453bbcfba6b9013020e2993004b24a1 100644 (file)
 #define debug(format, arg...)
 #endif
 
-#ifdef DEBUG
-#include <linux/highmem.h>
-
-static void dbg_dump_sg(const char *level, const char *prefix_str,
-                       int prefix_type, int rowsize, int groupsize,
-                       struct scatterlist *sg, size_t tlen, bool ascii)
-{
-       struct scatterlist *it;
-       void *it_page;
-       size_t len;
-       void *buf;
-
-       for (it = sg; it != NULL && tlen > 0 ; it = sg_next(sg)) {
-               /*
-                * make sure the scatterlist's page
-                * has a valid virtual memory mapping
-                */
-               it_page = kmap_atomic(sg_page(it));
-               if (unlikely(!it_page)) {
-                       printk(KERN_ERR "dbg_dump_sg: kmap failed\n");
-                       return;
-               }
-
-               buf = it_page + it->offset;
-               len = min_t(size_t, tlen, it->length);
-               print_hex_dump(level, prefix_str, prefix_type, rowsize,
-                              groupsize, buf, len, ascii);
-               tlen -= len;
-
-               kunmap_atomic(it_page);
-       }
-}
-#endif
-
 static struct list_head alg_list;
 
 struct caam_alg_entry {
@@ -898,10 +864,10 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
        print_hex_dump(KERN_ERR, "dstiv  @"__stringify(__LINE__)": ",
                       DUMP_PREFIX_ADDRESS, 16, 4, req->info,
                       edesc->src_nents > 1 ? 100 : ivsize, 1);
-       dbg_dump_sg(KERN_ERR, "dst    @"__stringify(__LINE__)": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
-                   edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
 #endif
+       caam_dump_sg(KERN_ERR, "dst    @" __stringify(__LINE__)": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
+                    edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
 
        ablkcipher_unmap(jrdev, edesc, req);
 
@@ -937,10 +903,10 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
        print_hex_dump(KERN_ERR, "dstiv  @"__stringify(__LINE__)": ",
                       DUMP_PREFIX_ADDRESS, 16, 4, req->info,
                       ivsize, 1);
-       dbg_dump_sg(KERN_ERR, "dst    @"__stringify(__LINE__)": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
-                   edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
 #endif
+       caam_dump_sg(KERN_ERR, "dst    @" __stringify(__LINE__)": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
+                    edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
 
        ablkcipher_unmap(jrdev, edesc, req);
 
@@ -1107,10 +1073,10 @@ static void init_ablkcipher_job(u32 *sh_desc, dma_addr_t ptr,
                       ivsize, 1);
        pr_err("asked=%d, nbytes%d\n",
               (int)edesc->src_nents > 1 ? 100 : req->nbytes, req->nbytes);
-       dbg_dump_sg(KERN_ERR, "src    @"__stringify(__LINE__)": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->src,
-                   edesc->src_nents > 1 ? 100 : req->nbytes, 1);
 #endif
+       caam_dump_sg(KERN_ERR, "src    @" __stringify(__LINE__)": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->src,
+                    edesc->src_nents > 1 ? 100 : req->nbytes, 1);
 
        len = desc_len(sh_desc);
        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,
        print_hex_dump(KERN_ERR, "presciv@" __stringify(__LINE__) ": ",
                       DUMP_PREFIX_ADDRESS, 16, 4, req->info,
                       ivsize, 1);
-       dbg_dump_sg(KERN_ERR, "src    @" __stringify(__LINE__) ": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->src,
-                   edesc->src_nents > 1 ? 100 : req->nbytes, 1);
 #endif
+       caam_dump_sg(KERN_ERR, "src    @" __stringify(__LINE__) ": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->src,
+                    edesc->src_nents > 1 ? 100 : req->nbytes, 1);
 
        len = desc_len(sh_desc);
        init_job_desc_shared(desc, ptr, len, HDR_SHARE_DEFER | HDR_REVERSE);
@@ -1449,11 +1415,9 @@ static int aead_decrypt(struct aead_request *req)
        u32 *desc;
        int ret = 0;
 
-#ifdef DEBUG
-       dbg_dump_sg(KERN_ERR, "dec src@"__stringify(__LINE__)": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->src,
-                   req->assoclen + req->cryptlen, 1);
-#endif
+       caam_dump_sg(KERN_ERR, "dec src@" __stringify(__LINE__)": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->src,
+                    req->assoclen + req->cryptlen, 1);
 
        /* allocate extended descriptor */
        edesc = aead_edesc_alloc(req, AUTHENC_DESC_JOB_IO_LEN,
index a614ea998a8764cc7459b6b9e2f4a5104be9ea82..058be8f094ee127d85c1aca979597d5c9c579a6c 100644 (file)
@@ -791,9 +791,9 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
        print_hex_dump(KERN_ERR, "dstiv  @" __stringify(__LINE__)": ",
                       DUMP_PREFIX_ADDRESS, 16, 4, req->info,
                       edesc->src_nents > 1 ? 100 : ivsize, 1);
-       dbg_dump_sg(KERN_ERR, "dst    @" __stringify(__LINE__)": ",
-                   DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
-                   edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
+       caam_dump_sg(KERN_ERR, "dst    @" __stringify(__LINE__)": ",
+                    DUMP_PREFIX_ADDRESS, 16, 4, req->dst,
+                    edesc->dst_nents > 1 ? 100 : req->nbytes, 1);
 #endif
 
        ablkcipher_unmap(qidev, edesc, req);
index 6f44ccb55c632e19bd683d1da5d487272a63b58d..3d639f3b45aa0d33b86e1ee0e96047ee6158fb4e 100644 (file)
@@ -9,6 +9,46 @@
 #include "desc.h"
 #include "error.h"
 
+#ifdef DEBUG
+#include <linux/highmem.h>
+
+void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
+                 int rowsize, int groupsize, struct scatterlist *sg,
+                 size_t tlen, bool ascii)
+{
+       struct scatterlist *it;
+       void *it_page;
+       size_t len;
+       void *buf;
+
+       for (it = sg; it && tlen > 0 ; it = sg_next(sg)) {
+               /*
+                * make sure the scatterlist's page
+                * has a valid virtual memory mapping
+                */
+               it_page = kmap_atomic(sg_page(it));
+               if (unlikely(!it_page)) {
+                       pr_err("caam_dump_sg: kmap failed\n");
+                       return;
+               }
+
+               buf = it_page + it->offset;
+               len = min_t(size_t, tlen, it->length);
+               print_hex_dump(level, prefix_str, prefix_type, rowsize,
+                              groupsize, buf, len, ascii);
+               tlen -= len;
+
+               kunmap_atomic(it_page);
+       }
+}
+#else
+void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
+                 int rowsize, int groupsize, struct scatterlist *sg,
+                 size_t tlen, bool ascii)
+{}
+#endif /* DEBUG */
+EXPORT_SYMBOL(caam_dump_sg);
+
 static const struct {
        u8 value;
        const char *error_text;
index b6350b0d91539023d98064015ff1ff2dc3a2a5bf..250e1a21c473e17744db32a598ac1b8b15a88755 100644 (file)
@@ -8,4 +8,8 @@
 #define CAAM_ERROR_H
 #define CAAM_ERROR_STR_MAX 302
 void caam_jr_strstatus(struct device *jrdev, u32 status);
+
+void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type,
+                 int rowsize, int groupsize, struct scatterlist *sg,
+                 size_t tlen, bool ascii);
 #endif /* CAAM_ERROR_H */