From patchwork Mon Nov 13 14:45:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 118808 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1132859edl; Mon, 13 Nov 2017 06:48:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMana79M2qwJwcOIjy4wDC4BQlbLpeB4V75SbSTf4Ql/GGjsaZOGP7rBJegxIqfmSOn1ARUh X-Received: by 10.159.205.132 with SMTP id v4mr9324893plo.426.1510584525055; Mon, 13 Nov 2017 06:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510584525; cv=none; d=google.com; s=arc-20160816; b=mjcLJYLBOxAvfNCTS7oz2SOUw8xhYz4kS++MdbOymZQxoXkJfxKWNMU2zfQPM9FeXe DxOnywj/jQ9HbTfBIskDRnONbo4tkSLAKFiy8E22LH+F1vAUF2/wFU5uEX8DtP53kNIw aH892o+OYhvRx2e7+w39pdb8lFOkUpGC1hYx7LDtyaNVxy/8wlX/rDAVtm+4XSHKy9Jh 8xWbwjJ2IuQqXihehGDycWq68zk3ose5bNYDlDWz9b0zVsISmaVwiePB6aAP2dNNj3ZI VYk854NiITDwqPIuGSMGkEMPbYq+AU6Nnc6ZW+hYo1bnloYvlc2LuNFtieepgy67BZSv /70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=m5IQvVYIDLl75Flkrdo4JGTu3kQMT5xH/UnYN32XRMU=; b=QRdVoAVaIikDl478sxtxAAhwEDn5HTwBH5mtPc6GKmdfzKqwqnWWYQI3UxIbZc8htH K7F97iZAo40WiHkIEt8ne+Ub3VXgBy8QdAqPnMrVIYvQMu5q/Tbxx+OBoydbFC7d9dGB gI4nXdcYH2F1MhtyQ2Wspg0+yC8B6tiJxpxhuxBLTvuMpgIkxp/Yw7t1W8w91DvSTY95 TAfPqiw1p8XqKKdBIfchH91MZsFI1wVIQd0svZ//9N1iAU3pQL+sMDgsRiI9YhKhSH5V azM+PxnjXkgQMgMRhfwRJg8IpBe0xwjRXpJ7mSD7ayI3fQSH/uDWV4GL1O+kNwgiiZ3+ uX2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si14160012plz.428.2017.11.13.06.48.44; Mon, 13 Nov 2017 06:48:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbdKMOsn (ORCPT + 27 others); Mon, 13 Nov 2017 09:48:43 -0500 Received: from foss.arm.com ([217.140.101.70]:47490 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753616AbdKMOsl (ORCPT ); Mon, 13 Nov 2017 09:48:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6BE81435; Mon, 13 Nov 2017 06:48:40 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 427693F318; Mon, 13 Nov 2017 06:48:39 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/24] staging: ccree: use local vars for readability Date: Mon, 13 Nov 2017 14:45:51 +0000 Message-Id: <1510584358-29473-24-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com> References: <1510584358-29473-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor cc_map_aead_request() to use local vars for addresses for better readability of code. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 64 +++++++++++++++------------------- 1 file changed, 29 insertions(+), 35 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 966033d..c542225 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -1259,7 +1259,7 @@ int cc_map_aead_request( int rc = 0; struct crypto_aead *tfm = crypto_aead_reqtfm(req); bool is_gcm4543 = areq_ctx->is_gcm4543; - + dma_addr_t dma_addr; u32 mapped_nents = 0; u32 dummy = 0; /*used for the assoc data fragments */ u32 size_to_map = 0; @@ -1281,32 +1281,31 @@ int cc_map_aead_request( req->cryptlen : (req->cryptlen - authsize); - areq_ctx->mac_buf_dma_addr = dma_map_single(dev, areq_ctx->mac_buf, - MAX_MAC_SIZE, - DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(dev, areq_ctx->mac_buf_dma_addr))) { + dma_addr = dma_map_single(dev, areq_ctx->mac_buf, MAX_MAC_SIZE, + DMA_BIDIRECTIONAL); + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n", MAX_MAC_SIZE, areq_ctx->mac_buf); rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->mac_buf_dma_addr = dma_addr; if (areq_ctx->ccm_hdr_size != ccm_header_size_null) { - areq_ctx->ccm_iv0_dma_addr = - dma_map_single(dev, (areq_ctx->ccm_config + - CCM_CTR_COUNT_0_OFFSET), - AES_BLOCK_SIZE, DMA_TO_DEVICE); + void *addr = areq_ctx->ccm_config + CCM_CTR_COUNT_0_OFFSET; - if (unlikely(dma_mapping_error(dev, - areq_ctx->ccm_iv0_dma_addr))) { + dma_addr = dma_map_single(dev, addr, AES_BLOCK_SIZE, + DMA_TO_DEVICE); + + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n", - AES_BLOCK_SIZE, - (areq_ctx->ccm_config + - CCM_CTR_COUNT_0_OFFSET)); + AES_BLOCK_SIZE, addr); areq_ctx->ccm_iv0_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->ccm_iv0_dma_addr = dma_addr; + if (ssi_aead_handle_config_buf(dev, areq_ctx, areq_ctx->ccm_config, &sg_data, req->assoclen)) { @@ -1317,54 +1316,49 @@ int cc_map_aead_request( #if SSI_CC_HAS_AES_GCM if (areq_ctx->cipher_mode == DRV_CIPHER_GCTR) { - areq_ctx->hkey_dma_addr = dma_map_single(dev, - areq_ctx->hkey, - AES_BLOCK_SIZE, - DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(dev, - areq_ctx->hkey_dma_addr))) { + dma_addr = dma_map_single(dev, areq_ctx->hkey, AES_BLOCK_SIZE, + DMA_BIDIRECTIONAL); + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping hkey %u B at va=%pK for DMA failed\n", AES_BLOCK_SIZE, areq_ctx->hkey); rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->hkey_dma_addr = dma_addr; - areq_ctx->gcm_block_len_dma_addr = - dma_map_single(dev, &areq_ctx->gcm_len_block, - AES_BLOCK_SIZE, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, - areq_ctx->gcm_block_len_dma_addr))) { + dma_addr = dma_map_single(dev, &areq_ctx->gcm_len_block, + AES_BLOCK_SIZE, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping gcm_len_block %u B at va=%pK for DMA failed\n", AES_BLOCK_SIZE, &areq_ctx->gcm_len_block); rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->gcm_block_len_dma_addr = dma_addr; - areq_ctx->gcm_iv_inc1_dma_addr = - dma_map_single(dev, areq_ctx->gcm_iv_inc1, - AES_BLOCK_SIZE, DMA_TO_DEVICE); + dma_addr = dma_map_single(dev, areq_ctx->gcm_iv_inc1, + AES_BLOCK_SIZE, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, - areq_ctx->gcm_iv_inc1_dma_addr))) { + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping gcm_iv_inc1 %u B at va=%pK for DMA failed\n", AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc1)); areq_ctx->gcm_iv_inc1_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->gcm_iv_inc1_dma_addr = dma_addr; - areq_ctx->gcm_iv_inc2_dma_addr = - dma_map_single(dev, areq_ctx->gcm_iv_inc2, - AES_BLOCK_SIZE, DMA_TO_DEVICE); + dma_addr = dma_map_single(dev, areq_ctx->gcm_iv_inc2, + AES_BLOCK_SIZE, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, - areq_ctx->gcm_iv_inc2_dma_addr))) { + if (unlikely(dma_mapping_error(dev, dma_addr))) { dev_err(dev, "Mapping gcm_iv_inc2 %u B at va=%pK for DMA failed\n", AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc2)); areq_ctx->gcm_iv_inc2_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; } + areq_ctx->gcm_iv_inc2_dma_addr = dma_addr; } #endif /*SSI_CC_HAS_AES_GCM*/