From patchwork Fri Jan 20 05:41:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 9527411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4478A60113 for ; Fri, 20 Jan 2017 05:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32EB428642 for ; Fri, 20 Jan 2017 05:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2786A2864D; Fri, 20 Jan 2017 05:42:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70C6A28642 for ; Fri, 20 Jan 2017 05:42:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cURyA-0002c1-NU; Fri, 20 Jan 2017 05:42:38 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cURxQ-0001Ws-UU; Fri, 20 Jan 2017 05:41:57 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 919077397; Fri, 20 Jan 2017 13:41:27 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Fri, 20 Jan 2017 13:41:28 +0800 From: Ryder Lee To: Herbert Xu , "David S. Miller" Subject: [PATCH 6/8] crypto: mediatek - fix typo and indentation Date: Fri, 20 Jan 2017 13:41:13 +0800 Message-ID: <1484890875-57105-7-git-send-email-ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484890875-57105-1-git-send-email-ryder.lee@mediatek.com> References: <1484890875-57105-1-git-send-email-ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170119_214153_280952_DE13BBFC X-CRM114-Status: GOOD ( 17.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryder Lee , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Dummy patch to fix typo and indentation. Signed-off-by: Ryder Lee --- drivers/crypto/mediatek/mtk-aes.c | 90 +++++++++++++++++----------------- drivers/crypto/mediatek/mtk-platform.h | 2 +- drivers/crypto/mediatek/mtk-sha.c | 40 +++++++-------- 3 files changed, 63 insertions(+), 69 deletions(-) diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index b5946e9..5e7c3ce 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -314,8 +314,8 @@ static int mtk_aes_map(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) aes->dst.sg_len = dma_map_sg(cryp->dev, aes->dst.sg, aes->dst.nents, DMA_FROM_DEVICE); if (unlikely(!aes->dst.sg_len)) { - dma_unmap_sg(cryp->dev, aes->src.sg, - aes->src.nents, DMA_TO_DEVICE); + dma_unmap_sg(cryp->dev, aes->src.sg, aes->src.nents, + DMA_TO_DEVICE); goto sg_map_err; } } @@ -484,7 +484,7 @@ static int mtk_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, u32 keylen) { struct mtk_aes_base_ctx *ctx = crypto_ablkcipher_ctx(tfm); - const u32 *key_tmp = (const u32 *)key; + const u32 *aes_key = (const u32 *)key; u32 *key_state = ctx->tfm.state; int i; @@ -498,7 +498,7 @@ static int mtk_aes_setkey(struct crypto_ablkcipher *tfm, ctx->keylen = SIZE_IN_WORDS(keylen); for (i = 0; i < ctx->keylen; i++) - key_state[i] = cpu_to_le32(key_tmp[i]); + key_state[i] = cpu_to_le32(aes_key[i]); return 0; } @@ -512,26 +512,26 @@ static int mtk_aes_crypt(struct ablkcipher_request *req, u64 mode) rctx = ablkcipher_request_ctx(req); rctx->mode = mode; - return mtk_aes_handle_queue(ctx->cryp, - !(mode & AES_FLAGS_ENCRYPT), &req->base); + return mtk_aes_handle_queue(ctx->cryp, !(mode & AES_FLAGS_ENCRYPT), + &req->base); } -static int mtk_ecb_encrypt(struct ablkcipher_request *req) +static int mtk_aes_ecb_encrypt(struct ablkcipher_request *req) { return mtk_aes_crypt(req, AES_FLAGS_ENCRYPT | AES_FLAGS_ECB); } -static int mtk_ecb_decrypt(struct ablkcipher_request *req) +static int mtk_aes_ecb_decrypt(struct ablkcipher_request *req) { return mtk_aes_crypt(req, AES_FLAGS_ECB); } -static int mtk_cbc_encrypt(struct ablkcipher_request *req) +static int mtk_aes_cbc_encrypt(struct ablkcipher_request *req) { return mtk_aes_crypt(req, AES_FLAGS_ENCRYPT | AES_FLAGS_CBC); } -static int mtk_cbc_decrypt(struct ablkcipher_request *req) +static int mtk_aes_cbc_decrypt(struct ablkcipher_request *req) { return mtk_aes_crypt(req, AES_FLAGS_CBC); } @@ -554,44 +554,44 @@ static int mtk_aes_cra_init(struct crypto_tfm *tfm) static struct crypto_alg aes_algs[] = { { - .cra_name = "cbc(aes)", - .cra_driver_name = "cbc-aes-mtk", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | - CRYPTO_ALG_ASYNC, - .cra_init = mtk_aes_cra_init, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct mtk_aes_ctx), - .cra_alignmask = 15, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_u.ablkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = mtk_aes_setkey, - .encrypt = mtk_cbc_encrypt, - .decrypt = mtk_cbc_decrypt, - .ivsize = AES_BLOCK_SIZE, + .cra_name = "cbc(aes)", + .cra_driver_name = "cbc-aes-mtk", + .cra_priority = 400, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | + CRYPTO_ALG_ASYNC, + .cra_init = mtk_aes_cra_init, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct mtk_aes_ctx), + .cra_alignmask = 0xf, + .cra_type = &crypto_ablkcipher_type, + .cra_module = THIS_MODULE, + .cra_u.ablkcipher = { + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = mtk_aes_setkey, + .encrypt = mtk_aes_cbc_encrypt, + .decrypt = mtk_aes_cbc_decrypt, + .ivsize = AES_BLOCK_SIZE, } }, { - .cra_name = "ecb(aes)", - .cra_driver_name = "ecb-aes-mtk", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | - CRYPTO_ALG_ASYNC, - .cra_init = mtk_aes_cra_init, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct mtk_aes_ctx), - .cra_alignmask = 15, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_u.ablkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = mtk_aes_setkey, - .encrypt = mtk_ecb_encrypt, - .decrypt = mtk_ecb_decrypt, + .cra_name = "ecb(aes)", + .cra_driver_name = "ecb-aes-mtk", + .cra_priority = 400, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | + CRYPTO_ALG_ASYNC, + .cra_init = mtk_aes_cra_init, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct mtk_aes_ctx), + .cra_alignmask = 0xf, + .cra_type = &crypto_ablkcipher_type, + .cra_module = THIS_MODULE, + .cra_u.ablkcipher = { + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = mtk_aes_setkey, + .encrypt = mtk_aes_ecb_encrypt, + .decrypt = mtk_aes_ecb_decrypt, } }, }; diff --git a/drivers/crypto/mediatek/mtk-platform.h b/drivers/crypto/mediatek/mtk-platform.h index 36d166b..7cd5f98 100644 --- a/drivers/crypto/mediatek/mtk-platform.h +++ b/drivers/crypto/mediatek/mtk-platform.h @@ -124,7 +124,7 @@ struct mtk_aes_dma { /** * struct mtk_aes_rec - AES operation record * @queue: crypto request queue - * @req: pointer to async request + * @areq: pointer to async request * @task: the tasklet is use in AES interrupt * @ctx: pointer to current context * @src: the structure that holds source sg list info diff --git a/drivers/crypto/mediatek/mtk-sha.c b/drivers/crypto/mediatek/mtk-sha.c index 2536ebc..55e3805 100644 --- a/drivers/crypto/mediatek/mtk-sha.c +++ b/drivers/crypto/mediatek/mtk-sha.c @@ -317,9 +317,9 @@ static void mtk_sha_info_init(struct mtk_sha_reqctx *ctx) * Update input data length field of transform information and * map it to DMA region. */ -static int mtk_sha_info_map(struct mtk_cryp *cryp, - struct mtk_sha_rec *sha, - size_t len) +static int mtk_sha_info_update(struct mtk_cryp *cryp, + struct mtk_sha_rec *sha, + size_t len) { struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); struct mtk_sha_info *info = &ctx->info; @@ -338,7 +338,7 @@ static int mtk_sha_info_map(struct mtk_cryp *cryp, ctx->digcnt += len; ctx->ct_dma = dma_map_single(cryp->dev, info, sizeof(*info), - DMA_BIDIRECTIONAL); + DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(cryp->dev, ctx->ct_dma))) { dev_err(cryp->dev, "dma %zu bytes error\n", sizeof(*info)); return -EINVAL; @@ -430,20 +430,15 @@ static int mtk_sha_xmit(struct mtk_cryp *cryp, struct mtk_sha_rec *sha, struct mtk_desc *res = ring->res_base + ring->res_pos; int err; - err = mtk_sha_info_map(cryp, sha, len); + err = mtk_sha_info_update(cryp, sha, len); if (err) return err; /* Fill in the command/result descriptors */ - res->hdr = MTK_DESC_FIRST | - MTK_DESC_LAST | - MTK_DESC_BUF_LEN(len); - + res->hdr = MTK_DESC_FIRST | MTK_DESC_LAST | MTK_DESC_BUF_LEN(len); res->buf = cpu_to_le32(cryp->tmp_dma); - cmd->hdr = MTK_DESC_FIRST | - MTK_DESC_LAST | - MTK_DESC_BUF_LEN(len) | + cmd->hdr = MTK_DESC_FIRST | MTK_DESC_LAST | MTK_DESC_BUF_LEN(len) | MTK_DESC_CT_LEN(ctx->ct_size); cmd->buf = cpu_to_le32(addr); @@ -477,7 +472,7 @@ static int mtk_sha_xmit2(struct mtk_cryp *cryp, struct mtk_desc *res = ring->res_base + ring->res_pos; int err; - err = mtk_sha_info_map(cryp, sha, len1 + len2); + err = mtk_sha_info_update(cryp, sha, len1 + len2); if (err) return err; @@ -485,8 +480,7 @@ static int mtk_sha_xmit2(struct mtk_cryp *cryp, res->hdr = MTK_DESC_BUF_LEN(len1) | MTK_DESC_FIRST; res->buf = cpu_to_le32(cryp->tmp_dma); - cmd->hdr = MTK_DESC_BUF_LEN(len1) | - MTK_DESC_FIRST | + cmd->hdr = MTK_DESC_BUF_LEN(len1) | MTK_DESC_FIRST | MTK_DESC_CT_LEN(ctx->ct_size); cmd->buf = cpu_to_le32(sg_dma_address(ctx->sg)); cmd->ct = cpu_to_le32(ctx->ct_dma); @@ -530,7 +524,7 @@ static int mtk_sha_dma_map(struct mtk_cryp *cryp, size_t count) { ctx->dma_addr = dma_map_single(cryp->dev, ctx->buffer, - SHA_BUF_SIZE, DMA_TO_DEVICE); + SHA_BUF_SIZE, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(cryp->dev, ctx->dma_addr))) { dev_err(cryp->dev, "dma map error\n"); return -EINVAL; @@ -619,7 +613,7 @@ static int mtk_sha_update_start(struct mtk_cryp *cryp, mtk_sha_fill_padding(ctx, len); ctx->dma_addr = dma_map_single(cryp->dev, ctx->buffer, - SHA_BUF_SIZE, DMA_TO_DEVICE); + SHA_BUF_SIZE, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(cryp->dev, ctx->dma_addr))) { dev_err(cryp->dev, "dma map bytes error\n"); return -EINVAL; @@ -658,8 +652,7 @@ static int mtk_sha_update_start(struct mtk_cryp *cryp, static int mtk_sha_final_req(struct mtk_cryp *cryp, struct mtk_sha_rec *sha) { - struct ahash_request *req = sha->req; - struct mtk_sha_reqctx *ctx = ahash_request_ctx(req); + struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); size_t count; mtk_sha_fill_padding(ctx, 0); @@ -690,7 +683,8 @@ static int mtk_sha_finish(struct ahash_request *req) } static void mtk_sha_finish_req(struct mtk_cryp *cryp, - struct mtk_sha_rec *sha, int err) + struct mtk_sha_rec *sha, + int err) { if (likely(!err && (SHA_FLAGS_FINAL & sha->flags))) err = mtk_sha_finish(sha->req); @@ -850,8 +844,8 @@ static int mtk_sha_digest(struct ahash_request *req) return mtk_sha_init(req) ?: mtk_sha_finup(req); } -static int mtk_sha_setkey(struct crypto_ahash *tfm, - const unsigned char *key, u32 keylen) +static int mtk_sha_setkey(struct crypto_ahash *tfm, const u8 *key, + u32 keylen) { struct mtk_sha_ctx *tctx = crypto_ahash_ctx(tfm); struct mtk_sha_hmac_ctx *bctx = tctx->base; @@ -863,7 +857,7 @@ static int mtk_sha_setkey(struct crypto_ahash *tfm, shash->tfm = bctx->shash; shash->flags = crypto_shash_get_flags(bctx->shash) & - CRYPTO_TFM_REQ_MAY_SLEEP; + CRYPTO_TFM_REQ_MAY_SLEEP; if (keylen > bs) { err = crypto_shash_digest(shash, key, keylen, bctx->ipad);