From patchwork Thu Nov 9 09:16:09 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: 118419 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6347065qgn; Thu, 9 Nov 2017 01:18:14 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q5/ykGU0ZR9HeVCnL8AYkRxEU9Fb8QeiCaBN6RZPFG/ayb106Mncl76Q7ot6MsSRh1kpi2 X-Received: by 10.98.189.23 with SMTP id a23mr3514097pff.124.1510219093928; Thu, 09 Nov 2017 01:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510219093; cv=none; d=google.com; s=arc-20160816; b=Dd0XoHtrJJl2Nrw0dcgmqQo4zDkbrf1g/k/zvmJT+XWVWQ4QKIeU9Vg9sNs9q81a/A +nnt3b6X/0D9MjFpYSRrr2Swa0O9/+k9okuMoRwzKIIoy7Pw5C8LlG5FBO0dRdDV02Jl 73YiBN9IgR42KgJ49ceL5Uqx7dHe0/MOLYRCLv9oGvCBWpl+sIvltpFIkRLc+zJT16F9 gFMG9+ztXx+wJSx569+V3FBOfs5MinrPhodXdH7Vg/kl4XxI0gc0YpZfnZIDaqT5luJY JDFKjvmOzSZWcThareV4xo/4xXIVnLqiyAgIcKgpdY6aW61qe82oMM8A8F054GgkhsIh 2ppQ== 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=V1aLQJ1FHFs+zSxrFBsGaR8L9yMAfcNKHFvhK7ExjhQ=; b=DGMr9b7Otr621d2NQJlDnlz7yapPtXrakVJFByTrw7OJbgiG28CCrk4T6nHhNuNn0w 0/fwejs7P9eXjof4nTUaxh9RVflvJtqZk0rq9O5MW46L9LtE2zWW9g/c3JEO+AHaK5Ly WIJcr50525Zhg7kGSv4cDEYayuouHakdGi+07P9KaLCQae2VXZLXpQQJznn+mnRT0KYn qgotP6o5l+5oyoitYIeO5ioWJi0+PJazbbYP5HuogC6ERLzLvD5+S044PCjVfA+EFg/O wtk1cWOlH2CbaNqM/x7Y/n2jHL/1zRxhNX6HfYKxvRV5ZKBBPHlJGYtvb+qafGmie+a9 mrJA== 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 j64si6251071pfe.155.2017.11.09.01.18.13; Thu, 09 Nov 2017 01:18:13 -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 S1754011AbdKIJSL (ORCPT + 25 others); Thu, 9 Nov 2017 04:18:11 -0500 Received: from foss.arm.com ([217.140.101.70]:43586 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753909AbdKIJLB (ORCPT ); Thu, 9 Nov 2017 04:11:01 -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 4D3651435; Thu, 9 Nov 2017 01:11:01 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 600CD3F246; Thu, 9 Nov 2017 01:10:59 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , stable , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/10] staging: ccree: fix leak of import() after init() Date: Thu, 9 Nov 2017 09:16:09 +0000 Message-Id: <1510218980-3549-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 crypto_ahash_import() may be called either after crypto_ahash_init() or without such call. Right now we always internally call init() as part of import(), thus leaking memory and mappings if the user has already called init() herself. Fix this by only calling init() internally if the state is not already initialized. Fixes: commit 454527d0d94f ("staging: ccree: fix hash import/export") Cc: stable Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_hash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index d79090e..1799d3f 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -1778,9 +1778,12 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in) } in += sizeof(u32); - rc = ssi_hash_init(state, ctx); - if (rc) - goto out; + /* call init() to allocate bufs if the user hasn't */ + if (!state->digest_buff) { + rc = ssi_hash_init(state, ctx); + if (rc) + goto out; + } dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); From patchwork Thu Nov 9 09:16:10 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: 118404 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6340920qgn; Thu, 9 Nov 2017 01:11:21 -0800 (PST) X-Google-Smtp-Source: ABhQp+TMbJak9pUETIO5jknJ14LmwdXQNRYLmE8rUKBG+PqdlJZ2xOSqlvA7cE3CCTUn0KfYlbQx X-Received: by 10.98.153.139 with SMTP id t11mr3467827pfk.210.1510218681028; Thu, 09 Nov 2017 01:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218681; cv=none; d=google.com; s=arc-20160816; b=xqES/3dSNABX4/QZISZtLwSvdl/y4MXmWe2ZeHOJa2iLrqjkGHi+rcgWlP9+yP//L/ z4w2f9j0UhRF1hgVbTcGRjbJ+fJYOUi/zu2YebbnUHc5iq0qXT59r//FA+nnjcj8mmPJ Zxv5r+N8Tr8/96RLPsKyPwFOCkyvi9N9BMQL8HV1UopppCpAJ0xrccaDOnXp5qwc/yA8 ZZrQEepvCqsRcJc2YGsaGnWS/+YPe9P2FZIF7VsvjUJ2iBJVL/2/9ybvL94tb4GFfSZf knyY2evVjxr4WTXYg9zoXzStF01RA8B8IUTXQlguI1sKJLjxgHT44jeoiUdUNnKKyk3J wNog== 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=p8r6p2puLMDyTqN/O3uQt25cx/Q84sLH6rPWeOTNGW8=; b=C9vZffMR1Ynr48fzE9XiATKz+f6s+1hOzM01wPSbxXpZvQi1hJbinhxwh41zbiDyXG raVEXaTJXIv5GEoGlN0BdpZjX+HKZZMLrxGaD1P/vFIaKlXljVLajPOn6hde8kuRNrAg Y9jgtrzW6UDnRISH8I38Q5HcjHeeapWEDCvywcIVRc2bNrqUABswn6we0TbEgxBaC0gx QJHvWk+xaqQZfy4fvtB1vh6bBf2IeNBbS2DFREkdYziwUwkSncscLAZ5BHSnVanbJACx 9Gti4Ssdc746xBGCfaJaCfdwDj2PK2rsrWeW6KBQF+jFN6SQUtS6OKkFc770d0JoRFtD aP9Q== 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 i187si6219163pfe.137.2017.11.09.01.11.20; Thu, 09 Nov 2017 01:11:21 -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 S1753955AbdKIJLS (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:18 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43602 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753927AbdKIJLF (ORCPT ); Thu, 9 Nov 2017 04:11:05 -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 8D8F71596; Thu, 9 Nov 2017 01:11:05 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C8FEE3F246; Thu, 9 Nov 2017 01:11:03 -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 v2 02/10] staging: ccree: make long func call sites readable Date: Thu, 9 Nov 2017 09:16:10 +0000 Message-Id: <1510218980-3549-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 The driver was using a function naming scheme including common prefixes for driver global functions based on the code module they came from. The combination of long names with long common prefixes made the whole thing too long for a human to parse. Switch to simple and shorter function naming scheme. Where required, realign parameters and add paranthesis for better code readability. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 32 +-- drivers/staging/ccree/ssi_buffer_mgr.c | 430 ++++++++++++++------------------ drivers/staging/ccree/ssi_buffer_mgr.h | 49 ++-- drivers/staging/ccree/ssi_cipher.c | 13 +- drivers/staging/ccree/ssi_driver.c | 18 +- drivers/staging/ccree/ssi_hash.c | 116 +++++---- drivers/staging/ccree/ssi_ivgen.c | 2 +- drivers/staging/ccree/ssi_pm.c | 26 +- drivers/staging/ccree/ssi_pm.h | 12 +- drivers/staging/ccree/ssi_request_mgr.c | 16 +- drivers/staging/ccree/ssi_request_mgr.h | 6 +- drivers/staging/ccree/ssi_sram_mgr.c | 11 +- drivers/staging/ccree/ssi_sram_mgr.h | 6 +- 13 files changed, 345 insertions(+), 392 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index ba0954e..0b5b230 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -233,7 +233,7 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); int err = 0; - ssi_buffer_mgr_unmap_aead_request(dev, areq); + cc_unmap_aead_request(dev, areq); /* Restore ordinary iv pointer */ areq->iv = areq_ctx->backup_iv; @@ -246,17 +246,20 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c /* In case of payload authentication failure, MUST NOT * revealed the decrypted message --> zero its memory. */ - ssi_buffer_mgr_zero_sgl(areq->dst, areq_ctx->cryptlen); + cc_zero_sgl(areq->dst, areq_ctx->cryptlen); err = -EBADMSG; } } else { /*ENCRYPT*/ - if (unlikely(areq_ctx->is_icv_fragmented)) - ssi_buffer_mgr_copy_scatterlist_portion( - dev, areq_ctx->mac_buf, areq_ctx->dst_sgl, - areq->cryptlen + areq_ctx->dst_offset, - (areq->cryptlen + areq_ctx->dst_offset + - ctx->authsize), - SSI_SG_FROM_BUF); + if (unlikely(areq_ctx->is_icv_fragmented)) { + cc_copy_sg_portion(dev, areq_ctx->mac_buf, + areq_ctx->dst_sgl, + (areq->cryptlen + + areq_ctx->dst_offset), + (areq->cryptlen + + areq_ctx->dst_offset + + ctx->authsize), + SSI_SG_FROM_BUF); + } /* If an IV was generated, copy it back to the user provided buffer. */ if (areq_ctx->backup_giv) { @@ -2053,7 +2056,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction } #endif /*SSI_CC_HAS_AES_GCM*/ - rc = ssi_buffer_mgr_map_aead_request(ctx->drvdata, req); + rc = cc_map_aead_request(ctx->drvdata, req); if (unlikely(rc != 0)) { dev_err(dev, "map_request() failed\n"); goto exit; @@ -2112,7 +2115,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction #endif default: dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode); - ssi_buffer_mgr_unmap_aead_request(dev, req); + cc_unmap_aead_request(dev, req); rc = -ENOTSUPP; goto exit; } @@ -2123,7 +2126,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_aead_request(dev, req); + cc_unmap_aead_request(dev, req); } exit: @@ -2753,8 +2756,9 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) INIT_LIST_HEAD(&aead_handle->aead_list); drvdata->aead_handle = aead_handle; - aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( - drvdata, MAX_HMAC_DIGEST_SIZE); + aead_handle->sram_workspace_addr = cc_sram_alloc(drvdata, + MAX_HMAC_DIGEST_SIZE); + if (aead_handle->sram_workspace_addr == NULL_SRAM_ADDR) { dev_err(dev, "SRAM pool exhausted\n"); rc = -ENOMEM; diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 1f8a225..2d971f2 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -65,13 +65,13 @@ struct buffer_array { }; /** - * ssi_buffer_mgr_get_sgl_nents() - Get scatterlist number of entries. + * cc_get_sgl_nents() - Get scatterlist number of entries. * * @sg_list: SG list * @nbytes: [IN] Total SGL data bytes. * @lbytes: [OUT] Returns the amount of bytes at the last entry */ -static unsigned int ssi_buffer_mgr_get_sgl_nents( +static unsigned int cc_get_sgl_nents( struct device *dev, struct scatterlist *sg_list, unsigned int nbytes, u32 *lbytes, bool *is_chained) { @@ -95,11 +95,11 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents( } /** - * ssi_buffer_mgr_zero_sgl() - Zero scatter scatter list data. + * cc_zero_sgl() - Zero scatter scatter list data. * * @sgl: */ -void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len) +void cc_zero_sgl(struct scatterlist *sgl, u32 data_len) { struct scatterlist *current_sg = sgl; int sg_index = 0; @@ -116,7 +116,7 @@ void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len) } /** - * ssi_buffer_mgr_copy_scatterlist_portion() - Copy scatter list data, + * cc_copy_sg_portion() - Copy scatter list data, * from to_skip to end, to dest and vice versa * * @dest: @@ -125,19 +125,19 @@ void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len) * @end: * @direct: */ -void ssi_buffer_mgr_copy_scatterlist_portion( +void cc_copy_sg_portion( struct device *dev, u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum ssi_sg_cpy_direct direct) { u32 nents, lbytes; - nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, end, &lbytes, NULL); + nents = cc_get_sgl_nents(dev, sg, end, &lbytes, NULL); sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, (direct == SSI_SG_TO_BUF)); } -static inline int ssi_buffer_mgr_render_buff_to_mlli( +static inline int cc_render_buff_to_mlli( struct device *dev, dma_addr_t buff_dma, u32 buff_size, u32 *curr_nents, u32 **mlli_entry_pp) { @@ -173,7 +173,7 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli( return 0; } -static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( +static inline int cc_render_sg_to_mlli( struct device *dev, struct scatterlist *sgl, u32 sgl_data_len, u32 sgl_offset, u32 *curr_nents, u32 **mlli_entry_pp) @@ -189,9 +189,9 @@ static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( sg_dma_len(curr_sgl) - sgl_offset : sgl_data_len; sgl_data_len -= entry_data_len; - rc = ssi_buffer_mgr_render_buff_to_mlli( - dev, sg_dma_address(curr_sgl) + sgl_offset, - entry_data_len, curr_nents, &mlli_entry_p); + rc = cc_render_buff_to_mlli(dev, sg_dma_address(curr_sgl) + + sgl_offset, entry_data_len, + curr_nents, &mlli_entry_p); if (rc != 0) return rc; @@ -201,7 +201,7 @@ static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( return 0; } -static int ssi_buffer_mgr_generate_mlli( +static int cc_generate_mlli( struct device *dev, struct buffer_array *sg_data, struct mlli_params *mlli_params) @@ -226,15 +226,15 @@ static int ssi_buffer_mgr_generate_mlli( /* go over all SG's and link it to one MLLI table */ for (i = 0; i < sg_data->num_of_buffers; i++) { if (sg_data->type[i] == DMA_SGL_TYPE) - rc = ssi_buffer_mgr_render_scatterlist_to_mlli( - dev, sg_data->entry[i].sgl, - sg_data->total_data_len[i], sg_data->offset[i], - &total_nents, &mlli_p); + rc = cc_render_sg_to_mlli(dev, sg_data->entry[i].sgl, + sg_data->total_data_len[i], + sg_data->offset[i], + &total_nents, &mlli_p); else /*DMA_BUFF_TYPE*/ - rc = ssi_buffer_mgr_render_buff_to_mlli( - dev, sg_data->entry[i].buffer_dma, - sg_data->total_data_len[i], &total_nents, - &mlli_p); + rc = cc_render_buff_to_mlli(dev, + sg_data->entry[i].buffer_dma, + sg_data->total_data_len[i], + &total_nents, &mlli_p); if (rc != 0) return rc; @@ -260,7 +260,7 @@ static int ssi_buffer_mgr_generate_mlli( return rc; } -static inline void ssi_buffer_mgr_add_buffer_entry( +static inline void cc_add_buffer_entry( struct device *dev, struct buffer_array *sgl_data, dma_addr_t buffer_dma, unsigned int buffer_len, bool is_last_entry, u32 *mlli_nents) @@ -281,7 +281,7 @@ static inline void ssi_buffer_mgr_add_buffer_entry( sgl_data->num_of_buffers++; } -static inline void ssi_buffer_mgr_add_scatterlist_entry( +static inline void cc_add_sg_entry( struct device *dev, struct buffer_array *sgl_data, unsigned int nents, @@ -308,8 +308,8 @@ static inline void ssi_buffer_mgr_add_scatterlist_entry( } static int -ssi_buffer_mgr_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents, - enum dma_data_direction direction) +cc_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents, + enum dma_data_direction direction) { u32 i, j; struct scatterlist *l_sg = sg; @@ -336,7 +336,7 @@ ssi_buffer_mgr_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents, return 0; } -static int ssi_buffer_mgr_map_scatterlist( +static int cc_map_sg( struct device *dev, struct scatterlist *sg, unsigned int nbytes, int direction, u32 *nents, u32 max_sg_nents, @@ -357,8 +357,8 @@ static int ssi_buffer_mgr_map_scatterlist( *nents = 1; *mapped_nents = 1; } else { /*sg_is_last*/ - *nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, nbytes, lbytes, - &is_chained); + *nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes, + &is_chained); if (*nents > max_sg_nents) { *nents = 0; dev_err(dev, "Too many fragments. current %d max %d\n", @@ -379,10 +379,8 @@ static int ssi_buffer_mgr_map_scatterlist( /*In this case the driver maps entry by entry so it * must have the same nents before and after map */ - *mapped_nents = ssi_buffer_mgr_dma_map_sg(dev, - sg, - *nents, - direction); + *mapped_nents = cc_dma_map_sg(dev, sg, *nents, + direction); if (unlikely(*mapped_nents != *nents)) { *nents = *mapped_nents; dev_err(dev, "dma_map_sg() sg buffer failed\n"); @@ -416,10 +414,9 @@ ssi_aead_handle_config_buf(struct device *dev, areq_ctx->ccm_adata_sg.offset, areq_ctx->ccm_adata_sg.length); /* prepare for case of MLLI */ if (assoclen > 0) { - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1, - &areq_ctx->ccm_adata_sg, - (AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size), - 0, false, NULL); + cc_add_sg_entry(dev, sg_data, 1, &areq_ctx->ccm_adata_sg, + (AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size), + 0, false, NULL); } return 0; } @@ -446,12 +443,12 @@ static inline int ssi_ahash_handle_curr_buf(struct device *dev, areq_ctx->curr_sg = areq_ctx->buff_sg; areq_ctx->in_nents = 0; /* prepare for case of MLLI */ - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1, areq_ctx->buff_sg, - curr_buff_cnt, 0, false, NULL); + cc_add_sg_entry(dev, sg_data, 1, areq_ctx->buff_sg, curr_buff_cnt, 0, + false, NULL); return 0; } -void ssi_buffer_mgr_unmap_blkcipher_request( +void cc_unmap_blkcipher_request( struct device *dev, void *ctx, unsigned int ivsize, @@ -484,7 +481,7 @@ void ssi_buffer_mgr_unmap_blkcipher_request( } } -int ssi_buffer_mgr_map_blkcipher_request( +int cc_map_blkcipher_request( struct ssi_drvdata *drvdata, void *ctx, unsigned int ivsize, @@ -527,11 +524,8 @@ int ssi_buffer_mgr_map_blkcipher_request( } /* Map the src SGL */ - rc = ssi_buffer_mgr_map_scatterlist(dev, src, - nbytes, DMA_BIDIRECTIONAL, - &req_ctx->in_nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, - &mapped_nents); + rc = cc_map_sg(dev, src, nbytes, DMA_BIDIRECTIONAL, &req_ctx->in_nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, &mapped_nents); if (unlikely(rc != 0)) { rc = -ENOMEM; goto ablkcipher_exit; @@ -543,19 +537,16 @@ int ssi_buffer_mgr_map_blkcipher_request( /* Handle inplace operation */ if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) { req_ctx->out_nents = 0; - ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, - req_ctx->in_nents, - src, nbytes, 0, - true, - &req_ctx->in_mlli_nents); + cc_add_sg_entry(dev, &sg_data, req_ctx->in_nents, src, + nbytes, 0, true, + &req_ctx->in_mlli_nents); } } else { /* Map the dst sg */ - if (unlikely(ssi_buffer_mgr_map_scatterlist( - dev, dst, nbytes, - DMA_BIDIRECTIONAL, &req_ctx->out_nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, - &mapped_nents))){ + if (unlikely(cc_map_sg(dev, dst, nbytes, DMA_BIDIRECTIONAL, + &req_ctx->out_nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, + &mapped_nents))) { rc = -ENOMEM; goto ablkcipher_exit; } @@ -563,22 +554,18 @@ int ssi_buffer_mgr_map_blkcipher_request( req_ctx->dma_buf_type = SSI_DMA_BUF_MLLI; if (unlikely((req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI))) { - ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, - req_ctx->in_nents, - src, nbytes, 0, - true, - &req_ctx->in_mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, - req_ctx->out_nents, - dst, nbytes, 0, - true, - &req_ctx->out_mlli_nents); + cc_add_sg_entry(dev, &sg_data, req_ctx->in_nents, src, + nbytes, 0, true, + &req_ctx->in_mlli_nents); + cc_add_sg_entry(dev, &sg_data, req_ctx->out_nents, dst, + nbytes, 0, true, + &req_ctx->out_mlli_nents); } } if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; - rc = ssi_buffer_mgr_generate_mlli(dev, &sg_data, mlli_params); + rc = cc_generate_mlli(dev, &sg_data, mlli_params); if (unlikely(rc != 0)) goto ablkcipher_exit; } @@ -589,12 +576,11 @@ int ssi_buffer_mgr_map_blkcipher_request( return 0; ablkcipher_exit: - ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); + cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); return rc; } -void ssi_buffer_mgr_unmap_aead_request( - struct device *dev, struct aead_request *req) +void cc_unmap_aead_request(struct device *dev, struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); unsigned int hw_iv_size = areq_ctx->hw_iv_size; @@ -668,16 +654,15 @@ void ssi_buffer_mgr_unmap_aead_request( size_to_unmap += crypto_aead_ivsize(tfm); dma_unmap_sg(dev, req->src, - ssi_buffer_mgr_get_sgl_nents(dev, req->src, size_to_unmap, - &dummy, &chained), + cc_get_sgl_nents(dev, req->src, size_to_unmap, + &dummy, &chained), DMA_BIDIRECTIONAL); if (unlikely(req->src != req->dst)) { dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", sg_virt(req->dst)); dma_unmap_sg(dev, req->dst, - ssi_buffer_mgr_get_sgl_nents(dev, req->dst, - size_to_unmap, - &dummy, &chained), + cc_get_sgl_nents(dev, req->dst, size_to_unmap, + &dummy, &chained), DMA_BIDIRECTIONAL); } if (drvdata->coherent && @@ -691,14 +676,15 @@ void ssi_buffer_mgr_unmap_aead_request( /* copy mac to a temporary location to deal with possible * data memory overriding that caused by cache coherence problem. */ - ssi_buffer_mgr_copy_scatterlist_portion( - dev, areq_ctx->backup_mac, req->src, - size_to_skip + req->cryptlen - areq_ctx->req_authsize, - size_to_skip + req->cryptlen, SSI_SG_FROM_BUF); + cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src, + (size_to_skip + req->cryptlen - + areq_ctx->req_authsize), + (size_to_skip + req->cryptlen), + SSI_SG_FROM_BUF); } } -static inline int ssi_buffer_mgr_get_aead_icv_nents( +static inline int cc_get_aead_icv_nents( struct device *dev, struct scatterlist *sgl, unsigned int sgl_nents, @@ -748,7 +734,7 @@ static inline int ssi_buffer_mgr_get_aead_icv_nents( return nents; } -static inline int ssi_buffer_mgr_aead_chain_iv( +static inline int cc_aead_chain_iv( struct ssi_drvdata *drvdata, struct aead_request *req, struct buffer_array *sg_data, @@ -780,11 +766,10 @@ static inline int ssi_buffer_mgr_aead_chain_iv( unsigned int iv_size_to_authenc = crypto_aead_ivsize(tfm); unsigned int iv_ofs = GCM_BLOCK_RFC4_IV_OFFSET; /* Chain to given list */ - ssi_buffer_mgr_add_buffer_entry( - dev, sg_data, - areq_ctx->gen_ctx.iv_dma_addr + iv_ofs, - iv_size_to_authenc, is_last, - &areq_ctx->assoc.mlli_nents); + cc_add_buffer_entry(dev, sg_data, + (areq_ctx->gen_ctx.iv_dma_addr + iv_ofs), + iv_size_to_authenc, is_last, + &areq_ctx->assoc.mlli_nents); areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; } @@ -792,7 +777,7 @@ static inline int ssi_buffer_mgr_aead_chain_iv( return rc; } -static inline int ssi_buffer_mgr_aead_chain_assoc( +static inline int cc_aead_chain_assoc( struct ssi_drvdata *drvdata, struct aead_request *req, struct buffer_array *sg_data, @@ -874,10 +859,9 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( dev_dbg(dev, "Chain assoc: buff_type=%s nents=%u\n", GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), areq_ctx->assoc.nents); - ssi_buffer_mgr_add_scatterlist_entry( - dev, sg_data, areq_ctx->assoc.nents, - req->src, req->assoclen, 0, is_last, - &areq_ctx->assoc.mlli_nents); + cc_add_sg_entry(dev, sg_data, areq_ctx->assoc.nents, req->src, + req->assoclen, 0, is_last, + &areq_ctx->assoc.mlli_nents); areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; } @@ -885,7 +869,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( return rc; } -static inline void ssi_buffer_mgr_prepare_aead_data_dlli( +static inline void cc_prepare_aead_data_dlli( struct aead_request *req, u32 *src_last_bytes, u32 *dst_last_bytes) { @@ -921,7 +905,7 @@ static inline void ssi_buffer_mgr_prepare_aead_data_dlli( } } -static inline int ssi_buffer_mgr_prepare_aead_data_mlli( +static inline int cc_prepare_aead_data_mlli( struct ssi_drvdata *drvdata, struct aead_request *req, struct buffer_array *sg_data, @@ -937,20 +921,15 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( if (likely(req->src == req->dst)) { /*INPLACE*/ - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, - areq_ctx->src.nents, - areq_ctx->src_sgl, - areq_ctx->cryptlen, - areq_ctx->src_offset, - is_last_table, - &areq_ctx->src.mlli_nents); - - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, - areq_ctx->src_sgl, - areq_ctx->src.nents, - authsize, - *src_last_bytes, - &areq_ctx->is_icv_fragmented); + cc_add_sg_entry(dev, sg_data, areq_ctx->src.nents, + areq_ctx->src_sgl, areq_ctx->cryptlen, + areq_ctx->src_offset, is_last_table, + &areq_ctx->src.mlli_nents); + + icv_nents = cc_get_aead_icv_nents(dev, areq_ctx->src_sgl, + areq_ctx->src.nents, + authsize, *src_last_bytes, + &areq_ctx->is_icv_fragmented); if (unlikely(icv_nents < 0)) { rc = -ENOTSUPP; goto prepare_data_mlli_exit; @@ -973,13 +952,12 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( if (areq_ctx->is_gcm4543) skip += crypto_aead_ivsize(tfm); - ssi_buffer_mgr_copy_scatterlist_portion( - dev, areq_ctx->backup_mac, - req->src, - (skip + req->cryptlen - - areq_ctx->req_authsize), - skip + req->cryptlen, - SSI_SG_TO_BUF); + cc_copy_sg_portion(dev, + areq_ctx->backup_mac, + req->src, + (skip + req->cryptlen - areq_ctx->req_authsize), + (skip + req->cryptlen), + SSI_SG_TO_BUF); } areq_ctx->icv_virt_addr = areq_ctx->backup_mac; } else { @@ -998,27 +976,19 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( } else if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) { /*NON-INPLACE and DECRYPT*/ - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, - areq_ctx->src.nents, - areq_ctx->src_sgl, - areq_ctx->cryptlen, - areq_ctx->src_offset, - is_last_table, - &areq_ctx->src.mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, - areq_ctx->dst.nents, - areq_ctx->dst_sgl, - areq_ctx->cryptlen, - areq_ctx->dst_offset, - is_last_table, - &areq_ctx->dst.mlli_nents); - - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, - areq_ctx->src_sgl, - areq_ctx->src.nents, - authsize, - *src_last_bytes, - &areq_ctx->is_icv_fragmented); + cc_add_sg_entry(dev, sg_data, areq_ctx->src.nents, + areq_ctx->src_sgl, areq_ctx->cryptlen, + areq_ctx->src_offset, is_last_table, + &areq_ctx->src.mlli_nents); + cc_add_sg_entry(dev, sg_data, areq_ctx->dst.nents, + areq_ctx->dst_sgl, areq_ctx->cryptlen, + areq_ctx->dst_offset, is_last_table, + &areq_ctx->dst.mlli_nents); + + icv_nents = cc_get_aead_icv_nents(dev, areq_ctx->src_sgl, + areq_ctx->src.nents, + authsize, *src_last_bytes, + &areq_ctx->is_icv_fragmented); if (unlikely(icv_nents < 0)) { rc = -ENOTSUPP; goto prepare_data_mlli_exit; @@ -1034,10 +1004,11 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( if (areq_ctx->is_gcm4543) size_to_skip += crypto_aead_ivsize(tfm); - ssi_buffer_mgr_copy_scatterlist_portion( - dev, areq_ctx->backup_mac, req->src, - size_to_skip + req->cryptlen - areq_ctx->req_authsize, - size_to_skip + req->cryptlen, SSI_SG_TO_BUF); + cc_copy_sg_portion(dev, areq_ctx->backup_mac, + req->src, + (size_to_skip + req->cryptlen - areq_ctx->req_authsize), + (size_to_skip + req->cryptlen), + SSI_SG_TO_BUF); areq_ctx->icv_virt_addr = areq_ctx->backup_mac; } else { /* Contig. ICV */ /*Should hanlde if the sg is not contig.*/ @@ -1051,27 +1022,19 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( } else { /*NON-INPLACE and ENCRYPT*/ - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, - areq_ctx->dst.nents, - areq_ctx->dst_sgl, - areq_ctx->cryptlen, - areq_ctx->dst_offset, - is_last_table, - &areq_ctx->dst.mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, - areq_ctx->src.nents, - areq_ctx->src_sgl, - areq_ctx->cryptlen, - areq_ctx->src_offset, - is_last_table, - &areq_ctx->src.mlli_nents); - - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, - areq_ctx->dst_sgl, - areq_ctx->dst.nents, - authsize, - *dst_last_bytes, - &areq_ctx->is_icv_fragmented); + cc_add_sg_entry(dev, sg_data, areq_ctx->dst.nents, + areq_ctx->dst_sgl, areq_ctx->cryptlen, + areq_ctx->dst_offset, is_last_table, + &areq_ctx->dst.mlli_nents); + cc_add_sg_entry(dev, sg_data, areq_ctx->src.nents, + areq_ctx->src_sgl, areq_ctx->cryptlen, + areq_ctx->src_offset, is_last_table, + &areq_ctx->src.mlli_nents); + + icv_nents = cc_get_aead_icv_nents(dev, areq_ctx->dst_sgl, + areq_ctx->dst.nents, + authsize, *dst_last_bytes, + &areq_ctx->is_icv_fragmented); if (unlikely(icv_nents < 0)) { rc = -ENOTSUPP; goto prepare_data_mlli_exit; @@ -1095,7 +1058,7 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( return rc; } -static inline int ssi_buffer_mgr_aead_chain_data( +static inline int cc_aead_chain_data( struct ssi_drvdata *drvdata, struct aead_request *req, struct buffer_array *sg_data, @@ -1131,10 +1094,8 @@ static inline int ssi_buffer_mgr_aead_chain_data( size_for_map += crypto_aead_ivsize(tfm); size_for_map += (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? authsize : 0; - src_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->src, - size_for_map, - &src_last_bytes, - &chained); + src_mapped_nents = cc_get_sgl_nents(dev, req->src, size_for_map, + &src_last_bytes, &chained); sg_index = areq_ctx->src_sgl->length; //check where the data starts while (sg_index <= size_to_skip) { @@ -1164,22 +1125,18 @@ static inline int ssi_buffer_mgr_aead_chain_data( if (is_gcm4543) size_for_map += crypto_aead_ivsize(tfm); - rc = ssi_buffer_mgr_map_scatterlist(dev, req->dst, size_for_map, - DMA_BIDIRECTIONAL, - &areq_ctx->dst.nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, - &dst_last_bytes, - &dst_mapped_nents); + rc = cc_map_sg(dev, req->dst, size_for_map, DMA_BIDIRECTIONAL, + &areq_ctx->dst.nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, &dst_last_bytes, + &dst_mapped_nents); if (unlikely(rc != 0)) { rc = -ENOMEM; goto chain_data_exit; } } - dst_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->dst, - size_for_map, - &dst_last_bytes, - &chained); + dst_mapped_nents = cc_get_sgl_nents(dev, req->dst, size_for_map, + &dst_last_bytes, &chained); sg_index = areq_ctx->dst_sgl->length; offset = size_to_skip; @@ -1206,23 +1163,21 @@ static inline int ssi_buffer_mgr_aead_chain_data( (dst_mapped_nents > 1) || do_chain) { areq_ctx->data_buff_type = SSI_DMA_BUF_MLLI; - rc = ssi_buffer_mgr_prepare_aead_data_mlli(drvdata, req, - sg_data, - &src_last_bytes, - &dst_last_bytes, - is_last_table); + rc = cc_prepare_aead_data_mlli(drvdata, req, sg_data, + &src_last_bytes, + &dst_last_bytes, is_last_table); } else { areq_ctx->data_buff_type = SSI_DMA_BUF_DLLI; - ssi_buffer_mgr_prepare_aead_data_dlli( - req, &src_last_bytes, &dst_last_bytes); + cc_prepare_aead_data_dlli(req, &src_last_bytes, + &dst_last_bytes); } chain_data_exit: return rc; } -static void ssi_buffer_mgr_update_aead_mlli_nents(struct ssi_drvdata *drvdata, - struct aead_request *req) +static void cc_update_aead_mlli_nents(struct ssi_drvdata *drvdata, + struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); u32 curr_mlli_size = 0; @@ -1272,7 +1227,7 @@ static void ssi_buffer_mgr_update_aead_mlli_nents(struct ssi_drvdata *drvdata, } } -int ssi_buffer_mgr_map_aead_request( +int cc_map_aead_request( struct ssi_drvdata *drvdata, struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); @@ -1303,10 +1258,10 @@ int ssi_buffer_mgr_map_aead_request( /* copy mac to a temporary location to deal with possible * data memory overriding that caused by cache coherence problem. */ - ssi_buffer_mgr_copy_scatterlist_portion( - dev, areq_ctx->backup_mac, req->src, - size_to_skip + req->cryptlen - areq_ctx->req_authsize, - size_to_skip + req->cryptlen, SSI_SG_TO_BUF); + cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src, + (size_to_skip + req->cryptlen - areq_ctx->req_authsize), + (size_to_skip + req->cryptlen), + SSI_SG_TO_BUF); } /* cacluate the size for cipher remove ICV in decrypt*/ @@ -1406,9 +1361,11 @@ int ssi_buffer_mgr_map_aead_request( if (is_gcm4543) size_to_map += crypto_aead_ivsize(tfm); - rc = ssi_buffer_mgr_map_scatterlist(dev, req->src, - size_to_map, DMA_BIDIRECTIONAL, &areq_ctx->src.nents, - LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES + LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, &mapped_nents); + rc = cc_map_sg(dev, req->src, size_to_map, DMA_BIDIRECTIONAL, + &areq_ctx->src.nents, + (LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES + + LLI_MAX_NUM_OF_DATA_ENTRIES), + &dummy, &mapped_nents); if (unlikely(rc != 0)) { rc = -ENOMEM; goto aead_map_failure; @@ -1421,13 +1378,13 @@ int ssi_buffer_mgr_map_aead_request( * (2) Src/Dst SGLs * Note: IV is contg. buffer (not an SGL) */ - rc = ssi_buffer_mgr_aead_chain_assoc(drvdata, req, &sg_data, true, false); + rc = cc_aead_chain_assoc(drvdata, req, &sg_data, true, false); if (unlikely(rc != 0)) goto aead_map_failure; - rc = ssi_buffer_mgr_aead_chain_iv(drvdata, req, &sg_data, true, false); + rc = cc_aead_chain_iv(drvdata, req, &sg_data, true, false); if (unlikely(rc != 0)) goto aead_map_failure; - rc = ssi_buffer_mgr_aead_chain_data(drvdata, req, &sg_data, true, false); + rc = cc_aead_chain_data(drvdata, req, &sg_data, true, false); if (unlikely(rc != 0)) goto aead_map_failure; } else { /* DOUBLE-PASS flow */ @@ -1451,13 +1408,13 @@ int ssi_buffer_mgr_map_aead_request( * (3) MLLI for src * (4) MLLI for dst */ - rc = ssi_buffer_mgr_aead_chain_assoc(drvdata, req, &sg_data, false, true); + rc = cc_aead_chain_assoc(drvdata, req, &sg_data, false, true); if (unlikely(rc != 0)) goto aead_map_failure; - rc = ssi_buffer_mgr_aead_chain_iv(drvdata, req, &sg_data, false, true); + rc = cc_aead_chain_iv(drvdata, req, &sg_data, false, true); if (unlikely(rc != 0)) goto aead_map_failure; - rc = ssi_buffer_mgr_aead_chain_data(drvdata, req, &sg_data, true, true); + rc = cc_aead_chain_data(drvdata, req, &sg_data, true, true); if (unlikely(rc != 0)) goto aead_map_failure; } @@ -1467,11 +1424,11 @@ int ssi_buffer_mgr_map_aead_request( (areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI) || (areq_ctx->data_buff_type == SSI_DMA_BUF_MLLI))) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; - rc = ssi_buffer_mgr_generate_mlli(dev, &sg_data, mlli_params); + rc = cc_generate_mlli(dev, &sg_data, mlli_params); if (unlikely(rc != 0)) goto aead_map_failure; - ssi_buffer_mgr_update_aead_mlli_nents(drvdata, req); + cc_update_aead_mlli_nents(drvdata, req); dev_dbg(dev, "assoc params mn %d\n", areq_ctx->assoc.mlli_nents); dev_dbg(dev, "src params mn %d\n", areq_ctx->src.mlli_nents); @@ -1480,12 +1437,13 @@ int ssi_buffer_mgr_map_aead_request( return 0; aead_map_failure: - ssi_buffer_mgr_unmap_aead_request(dev, req); + cc_unmap_aead_request(dev, req); return rc; } -int ssi_buffer_mgr_map_hash_request_final( - struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update) +int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, + struct scatterlist *src, unsigned int nbytes, + bool do_update) { struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; struct device *dev = drvdata_to_dev(drvdata); @@ -1522,12 +1480,10 @@ int ssi_buffer_mgr_map_hash_request_final( } if (src && (nbytes > 0) && do_update) { - if (unlikely(ssi_buffer_mgr_map_scatterlist(dev, src, nbytes, - DMA_TO_DEVICE, - &areq_ctx->in_nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, - &dummy, - &mapped_nents))){ + if (unlikely(cc_map_sg(dev, src, nbytes, DMA_TO_DEVICE, + &areq_ctx->in_nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, + &dummy, &mapped_nents))) { goto unmap_curr_buff; } if (src && (mapped_nents == 1) @@ -1546,12 +1502,9 @@ int ssi_buffer_mgr_map_hash_request_final( if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; /* add the src data to the sg_data */ - ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, - areq_ctx->in_nents, - src, nbytes, 0, true, - &areq_ctx->mlli_nents); - if (unlikely(ssi_buffer_mgr_generate_mlli(dev, &sg_data, - mlli_params) != 0)) { + cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes, + 0, true, &areq_ctx->mlli_nents); + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params) != 0)) { goto fail_unmap_din; } } @@ -1571,8 +1524,9 @@ int ssi_buffer_mgr_map_hash_request_final( return -ENOMEM; } -int ssi_buffer_mgr_map_hash_request_update( - struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size) +int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, + struct scatterlist *src, unsigned int nbytes, + unsigned int block_size) { struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; struct device *dev = drvdata_to_dev(drvdata); @@ -1606,8 +1560,7 @@ int ssi_buffer_mgr_map_hash_request_update( dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); areq_ctx->in_nents = - ssi_buffer_mgr_get_sgl_nents(dev, src, nbytes, &dummy, - NULL); + cc_get_sgl_nents(dev, src, nbytes, &dummy, NULL); sg_copy_to_buffer(src, areq_ctx->in_nents, &curr_buff[*curr_buff_cnt], nbytes); *curr_buff_cnt += nbytes; @@ -1627,9 +1580,9 @@ int ssi_buffer_mgr_map_hash_request_update( dev_dbg(dev, " handle residue: next buff %pK skip data %u residue %u\n", next_buff, (update_data_len - *curr_buff_cnt), *next_buff_cnt); - ssi_buffer_mgr_copy_scatterlist_portion(dev, next_buff, src, - (update_data_len - *curr_buff_cnt), - nbytes, SSI_SG_TO_BUF); + cc_copy_sg_portion(dev, next_buff, src, + (update_data_len - *curr_buff_cnt), + nbytes, SSI_SG_TO_BUF); /* change the buffer index for next operation */ swap_index = 1; } @@ -1644,13 +1597,11 @@ int ssi_buffer_mgr_map_hash_request_update( } if (update_data_len > *curr_buff_cnt) { - if (unlikely(ssi_buffer_mgr_map_scatterlist(dev, src, - (update_data_len - *curr_buff_cnt), - DMA_TO_DEVICE, - &areq_ctx->in_nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, - &dummy, - &mapped_nents))){ + if (unlikely(cc_map_sg(dev, src, + (update_data_len - *curr_buff_cnt), + DMA_TO_DEVICE, &areq_ctx->in_nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, + &mapped_nents))) { goto unmap_curr_buff; } if ((mapped_nents == 1) @@ -1669,15 +1620,10 @@ int ssi_buffer_mgr_map_hash_request_update( if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; /* add the src data to the sg_data */ - ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, - areq_ctx->in_nents, - src, - (update_data_len - *curr_buff_cnt), - 0, - true, - &areq_ctx->mlli_nents); - if (unlikely(ssi_buffer_mgr_generate_mlli(dev, &sg_data, - mlli_params) != 0)) { + cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, + (update_data_len - *curr_buff_cnt), 0, true, + &areq_ctx->mlli_nents); + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params) != 0)) { goto fail_unmap_din; } } @@ -1695,8 +1641,8 @@ int ssi_buffer_mgr_map_hash_request_update( return -ENOMEM; } -void ssi_buffer_mgr_unmap_hash_request( - struct device *dev, void *ctx, struct scatterlist *src, bool do_revert) +void cc_unmap_hash_request(struct device *dev, void *ctx, + struct scatterlist *src, bool do_revert) { struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; u32 *prev_len = areq_ctx->buff_index ? &areq_ctx->buff0_cnt : @@ -1736,7 +1682,7 @@ void ssi_buffer_mgr_unmap_hash_request( } } -int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) +int cc_buffer_mgr_init(struct ssi_drvdata *drvdata) { struct buff_mgr_handle *buff_mgr_handle; struct device *dev = drvdata_to_dev(drvdata); @@ -1759,11 +1705,11 @@ int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) return 0; error: - ssi_buffer_mgr_fini(drvdata); + cc_buffer_mgr_fini(drvdata); return -ENOMEM; } -int ssi_buffer_mgr_fini(struct ssi_drvdata *drvdata) +int cc_buffer_mgr_fini(struct ssi_drvdata *drvdata) { struct buff_mgr_handle *buff_mgr_handle = drvdata->buff_mgr_handle; diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h index 1032f25..f6411de 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.h +++ b/drivers/staging/ccree/ssi_buffer_mgr.h @@ -50,42 +50,39 @@ struct mlli_params { u32 mlli_len; }; -int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata); +int cc_buffer_mgr_init(struct ssi_drvdata *drvdata); -int ssi_buffer_mgr_fini(struct ssi_drvdata *drvdata); +int cc_buffer_mgr_fini(struct ssi_drvdata *drvdata); -int ssi_buffer_mgr_map_blkcipher_request( - struct ssi_drvdata *drvdata, - void *ctx, - unsigned int ivsize, - unsigned int nbytes, - void *info, - struct scatterlist *src, - struct scatterlist *dst); +int cc_map_blkcipher_request(struct ssi_drvdata *drvdata, void *ctx, + unsigned int ivsize, unsigned int nbytes, + void *info, struct scatterlist *src, + struct scatterlist *dst); -void ssi_buffer_mgr_unmap_blkcipher_request( - struct device *dev, - void *ctx, - unsigned int ivsize, - struct scatterlist *src, - struct scatterlist *dst); +void cc_unmap_blkcipher_request(struct device *dev, void *ctx, + unsigned int ivsize, + struct scatterlist *src, + struct scatterlist *dst); -int ssi_buffer_mgr_map_aead_request(struct ssi_drvdata *drvdata, struct aead_request *req); +int cc_map_aead_request(struct ssi_drvdata *drvdata, struct aead_request *req); -void ssi_buffer_mgr_unmap_aead_request(struct device *dev, struct aead_request *req); +void cc_unmap_aead_request(struct device *dev, struct aead_request *req); -int ssi_buffer_mgr_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update); +int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, + struct scatterlist *src, unsigned int nbytes, + bool do_update); -int ssi_buffer_mgr_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size); +int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, + struct scatterlist *src, unsigned int nbytes, + unsigned int block_size); -void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert); +void cc_unmap_hash_request(struct device *dev, void *ctx, + struct scatterlist *src, bool do_revert); -void ssi_buffer_mgr_copy_scatterlist_portion(struct device *dev, u8 *dest, - struct scatterlist *sg, - u32 to_skip, u32 end, - enum ssi_sg_cpy_direct direct); +void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, + u32 to_skip, u32 end, enum ssi_sg_cpy_direct direct); -void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len); +void cc_zero_sgl(struct scatterlist *sgl, u32 data_len); #endif /*__BUFFER_MGR_H__*/ diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index ee85cbf..721acf4 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -694,7 +694,7 @@ static int ssi_blkcipher_complete(struct device *dev, int completion_error = 0; struct ablkcipher_request *req = (struct ablkcipher_request *)areq; - ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); + cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); kfree(req_ctx->iv); if (areq) { @@ -786,9 +786,8 @@ static int ssi_blkcipher_process( /* STAT_PHASE_1: Map buffers */ - rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx, - ivsize, nbytes, req_ctx->iv, - src, dst); + rc = cc_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, + req_ctx->iv, src, dst); if (unlikely(rc != 0)) { dev_err(dev, "map_request() failed\n"); goto exit_process; @@ -823,12 +822,14 @@ static int ssi_blkcipher_process( if (areq) { if (unlikely(rc != -EINPROGRESS)) { /* Failed to send the request or request completed synchronously */ - ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); + cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, + dst); } } else { if (rc != 0) { - ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); + cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, + dst); } else { rc = ssi_blkcipher_complete(dev, ctx_p, req_ctx, dst, src, ivsize, NULL, diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 1a3c481..b9d1352 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -317,7 +317,7 @@ static int init_cc_resources(struct platform_device *plat_dev) } new_drvdata->mlli_sram_addr = - ssi_sram_mgr_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE); + cc_sram_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE); if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { dev_err(dev, "Failed to alloc MLLI Sram buffer\n"); rc = -ENOMEM; @@ -330,15 +330,15 @@ static int init_cc_resources(struct platform_device *plat_dev) goto post_sram_mgr_err; } - rc = ssi_buffer_mgr_init(new_drvdata); + rc = cc_buffer_mgr_init(new_drvdata); if (unlikely(rc != 0)) { dev_err(dev, "buffer_mgr_init failed\n"); goto post_req_mgr_err; } - rc = ssi_power_mgr_init(new_drvdata); + rc = cc_pm_init(new_drvdata); if (unlikely(rc != 0)) { - dev_err(dev, "ssi_power_mgr_init failed\n"); + dev_err(dev, "cc_pm_init failed\n"); goto post_buf_mgr_err; } @@ -383,9 +383,9 @@ static int init_cc_resources(struct platform_device *plat_dev) post_ivgen_err: ssi_ivgen_fini(new_drvdata); post_power_mgr_err: - ssi_power_mgr_fini(new_drvdata); + cc_pm_fini(new_drvdata); post_buf_mgr_err: - ssi_buffer_mgr_fini(new_drvdata); + cc_buffer_mgr_fini(new_drvdata); post_req_mgr_err: request_mgr_fini(new_drvdata); post_sram_mgr_err: @@ -418,8 +418,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) ssi_hash_free(drvdata); ssi_ablkcipher_free(drvdata); ssi_ivgen_fini(drvdata); - ssi_power_mgr_fini(drvdata); - ssi_buffer_mgr_fini(drvdata); + cc_pm_fini(drvdata); + cc_buffer_mgr_fini(drvdata); request_mgr_fini(drvdata); ssi_sram_mgr_fini(drvdata); ssi_fips_fini(drvdata); @@ -500,7 +500,7 @@ static int cc7x_remove(struct platform_device *plat_dev) #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) static const struct dev_pm_ops arm_cc7x_driver_pm = { - SET_RUNTIME_PM_OPS(ssi_power_mgr_runtime_suspend, ssi_power_mgr_runtime_resume, NULL) + SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL) }; #endif diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 1799d3f..eb9cb56 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -364,7 +364,7 @@ static void ssi_hash_update_complete(struct device *dev, void *ssi_req, void __i dev_dbg(dev, "req=%pK\n", req); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); + cc_unmap_hash_request(dev, state, req->src, false); req->base.complete(&req->base, 0); } @@ -378,7 +378,7 @@ static void ssi_hash_digest_complete(struct device *dev, void *ssi_req, void __i dev_dbg(dev, "req=%pK\n", req); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); + cc_unmap_hash_request(dev, state, req->src, false); ssi_hash_unmap_result(dev, state, digestsize, req->result); ssi_hash_unmap_request(dev, state, ctx); req->base.complete(&req->base, 0); @@ -394,7 +394,7 @@ static void ssi_hash_complete(struct device *dev, void *ssi_req, void __iomem *c dev_dbg(dev, "req=%pK\n", req); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); + cc_unmap_hash_request(dev, state, req->src, false); ssi_hash_unmap_result(dev, state, digestsize, req->result); ssi_hash_unmap_request(dev, state, ctx); req->base.complete(&req->base, 0); @@ -429,7 +429,8 @@ static int ssi_hash_digest(struct ahash_req_ctx *state, return -ENOMEM; } - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, + src, nbytes, 1) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -548,7 +549,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); ssi_hash_unmap_request(dev, state, ctx); } @@ -556,9 +557,9 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); } else { - ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); + cc_unmap_hash_request(dev, state, src, false); } ssi_hash_unmap_result(dev, state, digestsize, result); ssi_hash_unmap_request(dev, state, ctx); @@ -587,7 +588,8 @@ static int ssi_hash_update(struct ahash_req_ctx *state, return 0; } - rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, src, nbytes, block_size); + rc = cc_map_hash_request_update(ctx->drvdata, state, src, nbytes, + block_size); if (unlikely(rc)) { if (rc == 1) { dev_dbg(dev, " data size not require HW update %x\n", @@ -648,15 +650,15 @@ static int ssi_hash_update(struct ahash_req_ctx *state, rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); } else { - ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); + cc_unmap_hash_request(dev, state, src, false); } } return rc; @@ -680,7 +682,8 @@ static int ssi_hash_finup(struct ahash_req_ctx *state, dev_dbg(dev, "===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, src, + nbytes, 1) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -779,17 +782,17 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } else { - ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); + cc_unmap_hash_request(dev, state, src, false); ssi_hash_unmap_result(dev, state, digestsize, result); ssi_hash_unmap_request(dev, state, ctx); } @@ -815,7 +818,8 @@ static int ssi_hash_final(struct ahash_req_ctx *state, dev_dbg(dev, "===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 0) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, src, + nbytes, 0) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -924,17 +928,17 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); + cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } else { - ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); + cc_unmap_hash_request(dev, state, src, false); ssi_hash_unmap_result(dev, state, digestsize, result); ssi_hash_unmap_request(dev, state, ctx); } @@ -1372,7 +1376,8 @@ static int ssi_mac_update(struct ahash_request *req) state->xcbc_count++; - rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, req->src, req->nbytes, block_size); + rc = cc_map_hash_request_update(ctx->drvdata, state, req->src, + req->nbytes, block_size); if (unlikely(rc)) { if (rc == 1) { dev_dbg(dev, " data size not require HW update %x\n", @@ -1408,7 +1413,7 @@ static int ssi_mac_update(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); + cc_unmap_hash_request(dev, state, req->src, true); } return rc; } @@ -1440,7 +1445,8 @@ static int ssi_mac_final(struct ahash_request *req) dev_dbg(dev, "===== final xcbc reminder (%d) ====\n", rem_cnt); - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 0) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, + req->nbytes, 0) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -1518,7 +1524,7 @@ static int ssi_mac_final(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); + cc_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); } return rc; @@ -1543,7 +1549,8 @@ static int ssi_mac_finup(struct ahash_request *req) return ssi_mac_final(req); } - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, + req->nbytes, 1) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -1589,7 +1596,7 @@ static int ssi_mac_finup(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); + cc_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); } return rc; @@ -1619,7 +1626,8 @@ static int ssi_mac_digest(struct ahash_request *req) return -ENOMEM; } - if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { + if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, + req->nbytes, 1) != 0)) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -1661,7 +1669,7 @@ static int ssi_mac_digest(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); - ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); + cc_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); ssi_hash_unmap_request(dev, state, ctx); } @@ -2105,9 +2113,9 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) #endif /* Copy-to-sram digest-len */ - ssi_sram_mgr_const2sram_desc(digest_len_init, sram_buff_ofs, - ARRAY_SIZE(digest_len_init), - larval_seq, &larval_seq_len); + cc_set_sram_desc(digest_len_init, sram_buff_ofs, + ARRAY_SIZE(digest_len_init), larval_seq, + &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; @@ -2117,9 +2125,9 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) #if (DX_DEV_SHA_MAX > 256) /* Copy-to-sram digest-len for sha384/512 */ - ssi_sram_mgr_const2sram_desc(digest_len_sha512_init, sram_buff_ofs, - ARRAY_SIZE(digest_len_sha512_init), - larval_seq, &larval_seq_len); + cc_set_sram_desc(digest_len_sha512_init, sram_buff_ofs, + ARRAY_SIZE(digest_len_sha512_init), + larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; @@ -2132,36 +2140,36 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) hash_handle->larval_digest_sram_addr = sram_buff_ofs; /* Copy-to-sram initial SHA* digests */ - ssi_sram_mgr_const2sram_desc(md5_init, sram_buff_ofs, - ARRAY_SIZE(md5_init), larval_seq, - &larval_seq_len); + cc_set_sram_desc(md5_init, sram_buff_ofs, + ARRAY_SIZE(md5_init), larval_seq, + &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; sram_buff_ofs += sizeof(md5_init); larval_seq_len = 0; - ssi_sram_mgr_const2sram_desc(sha1_init, sram_buff_ofs, - ARRAY_SIZE(sha1_init), larval_seq, - &larval_seq_len); + cc_set_sram_desc(sha1_init, sram_buff_ofs, + ARRAY_SIZE(sha1_init), larval_seq, + &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; sram_buff_ofs += sizeof(sha1_init); larval_seq_len = 0; - ssi_sram_mgr_const2sram_desc(sha224_init, sram_buff_ofs, - ARRAY_SIZE(sha224_init), larval_seq, - &larval_seq_len); + cc_set_sram_desc(sha224_init, sram_buff_ofs, + ARRAY_SIZE(sha224_init), larval_seq, + &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; sram_buff_ofs += sizeof(sha224_init); larval_seq_len = 0; - ssi_sram_mgr_const2sram_desc(sha256_init, sram_buff_ofs, - ARRAY_SIZE(sha256_init), larval_seq, - &larval_seq_len); + cc_set_sram_desc(sha256_init, sram_buff_ofs, + ARRAY_SIZE(sha256_init), larval_seq, + &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) goto init_digest_const_err; @@ -2174,11 +2182,11 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) const u32 const0 = ((u32 *)((u64 *)&sha384_init[i]))[1]; const u32 const1 = ((u32 *)((u64 *)&sha384_init[i]))[0]; - ssi_sram_mgr_const2sram_desc(&const0, sram_buff_ofs, 1, - larval_seq, &larval_seq_len); + cc_set_sram_desc(&const0, sram_buff_ofs, 1, larval_seq, + &larval_seq_len); sram_buff_ofs += sizeof(u32); - ssi_sram_mgr_const2sram_desc(&const1, sram_buff_ofs, 1, - larval_seq, &larval_seq_len); + cc_set_sram_desc(&const1, sram_buff_ofs, 1, larval_seq, + &larval_seq_len); sram_buff_ofs += sizeof(u32); } rc = send_request_init(drvdata, larval_seq, larval_seq_len); @@ -2192,11 +2200,11 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) const u32 const0 = ((u32 *)((u64 *)&sha512_init[i]))[1]; const u32 const1 = ((u32 *)((u64 *)&sha512_init[i]))[0]; - ssi_sram_mgr_const2sram_desc(&const0, sram_buff_ofs, 1, - larval_seq, &larval_seq_len); + cc_set_sram_desc(&const0, sram_buff_ofs, 1, larval_seq, + &larval_seq_len); sram_buff_ofs += sizeof(u32); - ssi_sram_mgr_const2sram_desc(&const1, sram_buff_ofs, 1, - larval_seq, &larval_seq_len); + cc_set_sram_desc(&const1, sram_buff_ofs, 1, larval_seq, + &larval_seq_len); sram_buff_ofs += sizeof(u32); } rc = send_request_init(drvdata, larval_seq, larval_seq_len); @@ -2237,7 +2245,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) sizeof(sha224_init) + sizeof(sha256_init); - sram_buff = ssi_sram_mgr_alloc(drvdata, sram_size_to_alloc); + sram_buff = cc_sram_alloc(drvdata, sram_size_to_alloc); if (sram_buff == NULL_SRAM_ADDR) { dev_err(dev, "SRAM pool exhausted\n"); rc = -ENOMEM; diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 3f082f4..0d85bce 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -209,7 +209,7 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) goto out; } /* Allocate IV pool in SRAM */ - ivgen_ctx->pool = ssi_sram_mgr_alloc(drvdata, SSI_IVPOOL_SIZE); + ivgen_ctx->pool = cc_sram_alloc(drvdata, SSI_IVPOOL_SIZE); if (ivgen_ctx->pool == NULL_SRAM_ADDR) { dev_err(device, "SRAM pool exhausted\n"); rc = -ENOMEM; diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index 36a4980..e1bc4c5 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -34,7 +34,7 @@ #define POWER_DOWN_ENABLE 0x01 #define POWER_DOWN_DISABLE 0x00 -int ssi_power_mgr_runtime_suspend(struct device *dev) +int cc_pm_suspend(struct device *dev) { struct ssi_drvdata *drvdata = (struct ssi_drvdata *)dev_get_drvdata(dev); @@ -42,9 +42,9 @@ int ssi_power_mgr_runtime_suspend(struct device *dev) dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); - rc = ssi_request_mgr_runtime_suspend_queue(drvdata); + rc = cc_suspend_req_queue(drvdata); if (rc != 0) { - dev_err(dev, "ssi_request_mgr_runtime_suspend_queue (%x)\n", + dev_err(dev, "cc_suspend_req_queue (%x)\n", rc); return rc; } @@ -53,7 +53,7 @@ int ssi_power_mgr_runtime_suspend(struct device *dev) return 0; } -int ssi_power_mgr_runtime_resume(struct device *dev) +int cc_pm_resume(struct device *dev) { int rc; struct ssi_drvdata *drvdata = @@ -74,9 +74,9 @@ int ssi_power_mgr_runtime_resume(struct device *dev) return rc; } - rc = ssi_request_mgr_runtime_resume_queue(drvdata); + rc = cc_resume_req_queue(drvdata); if (rc != 0) { - dev_err(dev, "ssi_request_mgr_runtime_resume_queue (%x)\n", rc); + dev_err(dev, "cc_resume_req_queue (%x)\n", rc); return rc; } @@ -87,12 +87,11 @@ int ssi_power_mgr_runtime_resume(struct device *dev) return 0; } -int ssi_power_mgr_runtime_get(struct device *dev) +int cc_pm_get(struct device *dev) { int rc = 0; - if (ssi_request_mgr_is_queue_runtime_suspend( - (struct ssi_drvdata *)dev_get_drvdata(dev))) { + if (cc_req_queue_suspended((struct ssi_drvdata *)dev_get_drvdata(dev))) { rc = pm_runtime_get_sync(dev); } else { pm_runtime_get_noresume(dev); @@ -100,12 +99,11 @@ int ssi_power_mgr_runtime_get(struct device *dev) return rc; } -int ssi_power_mgr_runtime_put_suspend(struct device *dev) +int cc_pm_put_suspend(struct device *dev) { int rc = 0; - if (!ssi_request_mgr_is_queue_runtime_suspend( - (struct ssi_drvdata *)dev_get_drvdata(dev))) { + if (!cc_req_queue_suspended((struct ssi_drvdata *)dev_get_drvdata(dev))) { pm_runtime_mark_last_busy(dev); rc = pm_runtime_put_autosuspend(dev); } else { @@ -118,7 +116,7 @@ int ssi_power_mgr_runtime_put_suspend(struct device *dev) #endif -int ssi_power_mgr_init(struct ssi_drvdata *drvdata) +int cc_pm_init(struct ssi_drvdata *drvdata) { int rc = 0; #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) @@ -137,7 +135,7 @@ int ssi_power_mgr_init(struct ssi_drvdata *drvdata) return rc; } -void ssi_power_mgr_fini(struct ssi_drvdata *drvdata) +void cc_pm_fini(struct ssi_drvdata *drvdata) { #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) pm_runtime_disable(drvdata_to_dev(drvdata)); diff --git a/drivers/staging/ccree/ssi_pm.h b/drivers/staging/ccree/ssi_pm.h index 63673f6..557ec98 100644 --- a/drivers/staging/ccree/ssi_pm.h +++ b/drivers/staging/ccree/ssi_pm.h @@ -25,18 +25,18 @@ #define SSI_SUSPEND_TIMEOUT 3000 -int ssi_power_mgr_init(struct ssi_drvdata *drvdata); +int cc_pm_init(struct ssi_drvdata *drvdata); -void ssi_power_mgr_fini(struct ssi_drvdata *drvdata); +void cc_pm_fini(struct ssi_drvdata *drvdata); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) -int ssi_power_mgr_runtime_suspend(struct device *dev); +int cc_pm_suspend(struct device *dev); -int ssi_power_mgr_runtime_resume(struct device *dev); +int cc_pm_resume(struct device *dev); -int ssi_power_mgr_runtime_get(struct device *dev); +int cc_pm_get(struct device *dev); -int ssi_power_mgr_runtime_put_suspend(struct device *dev); +int cc_pm_put_suspend(struct device *dev); #endif #endif /*__POWER_MGR_H__*/ diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index a8a7dc6..f5d51c1 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -274,9 +274,9 @@ int send_request( (!is_dout ? 1 : 0)); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - rc = ssi_power_mgr_runtime_get(dev); + rc = cc_pm_get(dev); if (rc != 0) { - dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc); + dev_err(dev, "cc_pm_get returned %x\n", rc); return rc; } #endif @@ -301,7 +301,7 @@ int send_request( * (SW queue is full) */ #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - ssi_power_mgr_runtime_put_suspend(dev); + cc_pm_put_suspend(dev); #endif return rc; } @@ -337,7 +337,7 @@ int send_request( dev_err(dev, "Failed to generate IV (rc=%d)\n", rc); spin_unlock_bh(&req_mgr_h->hw_lock); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - ssi_power_mgr_runtime_put_suspend(dev); + cc_pm_put_suspend(dev); #endif return rc; } @@ -499,7 +499,7 @@ static void proc_completions(struct ssi_drvdata *drvdata) dev_dbg(dev, "Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - rc = ssi_power_mgr_runtime_put_suspend(dev); + rc = cc_pm_put_suspend(dev); if (rc != 0) dev_err(dev, "Failed to set runtime suspension %d\n", rc); @@ -565,7 +565,7 @@ static void comp_handler(unsigned long devarg) * the spin lock protection */ #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) -int ssi_request_mgr_runtime_resume_queue(struct ssi_drvdata *drvdata) +int cc_resume_req_queue(struct ssi_drvdata *drvdata) { struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle; @@ -580,7 +580,7 @@ int ssi_request_mgr_runtime_resume_queue(struct ssi_drvdata *drvdata) * suspend the queue configuration. Since it is used for the runtime suspend * only verify that the queue can be suspended. */ -int ssi_request_mgr_runtime_suspend_queue(struct ssi_drvdata *drvdata) +int cc_suspend_req_queue(struct ssi_drvdata *drvdata) { struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle; @@ -598,7 +598,7 @@ int ssi_request_mgr_runtime_suspend_queue(struct ssi_drvdata *drvdata) return 0; } -bool ssi_request_mgr_is_queue_runtime_suspend(struct ssi_drvdata *drvdata) +bool cc_req_queue_suspended(struct ssi_drvdata *drvdata) { struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle; diff --git a/drivers/staging/ccree/ssi_request_mgr.h b/drivers/staging/ccree/ssi_request_mgr.h index bdbbf89..ba44ab4 100644 --- a/drivers/staging/ccree/ssi_request_mgr.h +++ b/drivers/staging/ccree/ssi_request_mgr.h @@ -50,11 +50,11 @@ void complete_request(struct ssi_drvdata *drvdata); void request_mgr_fini(struct ssi_drvdata *drvdata); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) -int ssi_request_mgr_runtime_resume_queue(struct ssi_drvdata *drvdata); +int cc_resume_req_queue(struct ssi_drvdata *drvdata); -int ssi_request_mgr_runtime_suspend_queue(struct ssi_drvdata *drvdata); +int cc_suspend_req_queue(struct ssi_drvdata *drvdata); -bool ssi_request_mgr_is_queue_runtime_suspend(struct ssi_drvdata *drvdata); +bool cc_req_queue_suspended(struct ssi_drvdata *drvdata); #endif #endif /*__REQUEST_MGR_H__*/ diff --git a/drivers/staging/ccree/ssi_sram_mgr.c b/drivers/staging/ccree/ssi_sram_mgr.c index 07260d1..51513248 100644 --- a/drivers/staging/ccree/ssi_sram_mgr.c +++ b/drivers/staging/ccree/ssi_sram_mgr.c @@ -69,7 +69,7 @@ int ssi_sram_mgr_init(struct ssi_drvdata *drvdata) * \param drvdata * \param size The requested bytes to allocate */ -ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size) +ssi_sram_addr_t cc_sram_alloc(struct ssi_drvdata *drvdata, u32 size) { struct ssi_sram_mgr_ctx *smgr_ctx = drvdata->sram_mgr_handle; struct device *dev = drvdata_to_dev(drvdata); @@ -93,7 +93,7 @@ ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size) } /** - * ssi_sram_mgr_const2sram_desc() - Create const descriptors sequence to + * cc_set_sram_desc() - Create const descriptors sequence to * set values in given array into SRAM. * Note: each const value can't exceed word size. * @@ -103,10 +103,9 @@ ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size) * @seq: A pointer to the given IN/OUT descriptor sequence * @seq_len: A pointer to the given IN/OUT sequence length */ -void ssi_sram_mgr_const2sram_desc( - const u32 *src, ssi_sram_addr_t dst, - unsigned int nelement, - struct cc_hw_desc *seq, unsigned int *seq_len) +void cc_set_sram_desc(const u32 *src, ssi_sram_addr_t dst, + unsigned int nelement, struct cc_hw_desc *seq, + unsigned int *seq_len) { u32 i; unsigned int idx = *seq_len; diff --git a/drivers/staging/ccree/ssi_sram_mgr.h b/drivers/staging/ccree/ssi_sram_mgr.h index 9ba1d59..9e39262 100644 --- a/drivers/staging/ccree/ssi_sram_mgr.h +++ b/drivers/staging/ccree/ssi_sram_mgr.h @@ -58,10 +58,10 @@ void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata); * \param drvdata * \param size The requested bytes to allocate */ -ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size); +ssi_sram_addr_t cc_sram_alloc(struct ssi_drvdata *drvdata, u32 size); /** - * ssi_sram_mgr_const2sram_desc() - Create const descriptors sequence to + * cc_set_sram_desc() - Create const descriptors sequence to * set values in given array into SRAM. * Note: each const value can't exceed word size. * @@ -71,7 +71,7 @@ ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size); * @seq: A pointer to the given IN/OUT descriptor sequence * @seq_len: A pointer to the given IN/OUT sequence length */ -void ssi_sram_mgr_const2sram_desc( +void cc_set_sram_desc( const u32 *src, ssi_sram_addr_t dst, unsigned int nelement, struct cc_hw_desc *seq, unsigned int *seq_len); From patchwork Thu Nov 9 09:16:11 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: 118418 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6346683qgn; Thu, 9 Nov 2017 01:17:50 -0800 (PST) X-Google-Smtp-Source: ABhQp+R77PqgiZ7ViEnsfvDnsV7jANvJHKttKz+VclEDCmEhLZmmAX/A5siJ6AgyRHOoc7Ij0o7b X-Received: by 10.99.63.3 with SMTP id m3mr599964pga.384.1510219070231; Thu, 09 Nov 2017 01:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510219070; cv=none; d=google.com; s=arc-20160816; b=JAVrXI0pV5q38bao6wXsx+CHoo9+SXRUCjqXkOdkqNeGEyn3Yy9wjN2jY8alBfFJWA IIpJcPBXjJyIqFnI7KjGEmtwxUL7Jgve/uJ6EQ4oIjNY90qUM+Djh0tInx5xts73ZFcS BDui0ZWGpfBAsKg8BpoxG114VqrNtEHudqkk/QfLMugnyoQh/akfq4W4qruprLquwRb5 YdPuGzwJgiwxbxJD3Xu5JHBTtx7e8W529ctR/kH48btb5MyMnJ3XUCOhK/aChGYJygtT UHAapDBi3yZEN4MWFtIJrnuwY+3J42cjRPxQ250PFx8U5OACNWW/NOObo85BB+Y5z34X nzoA== 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=LRizy4W3EfBZZnQPp5CO8iV5kEFlWBSFvWVNVyfOcpo=; b=QOpyZ60AZ8ok9Qh7mB4Konu2buUo8XI1vWozNfC3TTqPitcy9EIveKZ7BRYtbsDa9Y ms/okYSNLYYke3nXXtDYqaFFtDkjh7H/TAbCGnik3AvuGLPdpEbltQib3F6PZJz6q3kS fEoWrnwl2eD8O75j6U5sBgVs343bTE5fO4DfLiWtBlOEnDppsIu/ZfhdveyUM5Su4DbU j4vKar9AhOKnaigJt3wxxVNehRgos+Db0ACcwuhj+wOYW/ejXCBA4MzMknZnUHQXqFos TozHeViX9fGmzCWOTD/79OdDw53eW6MlBD2oIf2hfkagJRaJ5NovOAj75VcPvJkFKGT/ EoQA== 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 n9si5872415pgc.688.2017.11.09.01.17.49; Thu, 09 Nov 2017 01:17:50 -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 S1754104AbdKIJRq (ORCPT + 25 others); Thu, 9 Nov 2017 04:17:46 -0500 Received: from foss.arm.com ([217.140.101.70]:43604 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753925AbdKIJLK (ORCPT ); Thu, 9 Nov 2017 04:11:10 -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 AF9A11435; Thu, 9 Nov 2017 01:11:10 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 541973F246; Thu, 9 Nov 2017 01:11:08 -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 v2 03/10] staging: ccree: simplify AEAD using local var Date: Thu, 9 Nov 2017 09:16:11 +0000 Message-Id: <1510218980-3549-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Make the code more readable by using a local variable for commonly use expression in the AEAD part of the driver. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index 0b5b230..a8e1371 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -251,13 +251,11 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c } } else { /*ENCRYPT*/ if (unlikely(areq_ctx->is_icv_fragmented)) { + u32 skip = areq->cryptlen + areq_ctx->dst_offset; + cc_copy_sg_portion(dev, areq_ctx->mac_buf, - areq_ctx->dst_sgl, - (areq->cryptlen + - areq_ctx->dst_offset), - (areq->cryptlen + - areq_ctx->dst_offset + - ctx->authsize), + areq_ctx->dst_sgl, skip, + (skip + ctx->authsize), SSI_SG_FROM_BUF); } From patchwork Thu Nov 9 09:16:12 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: 118410 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6344340qgn; Thu, 9 Nov 2017 01:15:12 -0800 (PST) X-Google-Smtp-Source: ABhQp+REu9cnkm41Tok4D+u9egTFSrBUX1ItZb6JAnvNxtUIdhBoPP5oyWX/eo0TS2jfinegO7s7 X-Received: by 10.99.178.15 with SMTP id x15mr3260752pge.243.1510218912442; Thu, 09 Nov 2017 01:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218912; cv=none; d=google.com; s=arc-20160816; b=BCWWf2okGdDxpnpfzffJRXX/ZnjwON6OR+YZJtsCSfwXs0N7xAkaCLoXerORowVhEx Nh0MAQeM/aZtMTaWFLPWrIworC+5Pe7zenc1cKaE10Wmywon61S+OXPlGztfRx8WXmEG OWpffmT0Tr0kWReKCJK9eWPZMSFYdCf/HL2D/hL66V2quJyTy1gtwbiBgWMoD29/r+zi AcYzhU6j/Zbd4ZD3FlTGwdFwzaCzLcT49yF0Pmq0KD0eCxPVQlGCfj7L73UDu6U1aK5g T3lel9TjG5LplX8M0d1e/OIYFT26s1X4PDmGMzPWi92YsNdt6mWuiFno0UiWNDz4DZYV /Q6g== 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=784FYCPwJeNBDCxwf55rekRs5Wy8mND1KEuUFUIcxNE=; b=vO50qtROjNotlr8X8k+b5L7OXmVqLFZm3HlcufL2Pb+ScJ6U6jKCJkvHaao4np2GDT IZmerC/cX7WTAbjIOLpKaRu8zS++3lNKbfE+UjIT3Y3TjbUoHZEoT7+79NYgtB+sq49p smUNxzC+co1ag13ujK4yJwUVksSgmuorNj2j/+nJx3M7RFTBgRiKDBtcccY3BHnGkJJH WOm9bxp1nvAaJ3uh+Jg2rhFZZ74MQa/PxXNuoty5HNkl2oUgstG025r8abkVLEr0aRLY XiT9MW3OhMroFFsNCHkC7ktRTs/alMnIAOlKDQREGva3gGbHIj6bNDCbmnXcCIR9wwUc GqMQ== 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 p189si4410212pfp.296.2017.11.09.01.15.11; Thu, 09 Nov 2017 01:15:12 -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 S1753979AbdKIJL3 (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:29 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43618 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753956AbdKIJLT (ORCPT ); Thu, 9 Nov 2017 04:11:19 -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 6809E1435; Thu, 9 Nov 2017 01:11:19 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D07513F246; Thu, 9 Nov 2017 01:11:13 -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 v2 04/10] staging: ccree: simplify buf mgr using local vars Date: Thu, 9 Nov 2017 09:16:12 +0000 Message-Id: <1510218980-3549-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Make the code more readable by using a local variables for commonly use expressions in the buffer manager part of the driver. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 2d971f2..b3ca249 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -225,16 +225,18 @@ static int cc_generate_mlli( mlli_p = (u32 *)mlli_params->mlli_virt_addr; /* go over all SG's and link it to one MLLI table */ for (i = 0; i < sg_data->num_of_buffers; i++) { + union buffer_array_entry *entry = &sg_data->entry[i]; + u32 tot_len = sg_data->total_data_len[i]; + u32 offset = sg_data->offset[i]; + if (sg_data->type[i] == DMA_SGL_TYPE) - rc = cc_render_sg_to_mlli(dev, sg_data->entry[i].sgl, - sg_data->total_data_len[i], - sg_data->offset[i], - &total_nents, &mlli_p); + rc = cc_render_sg_to_mlli(dev, entry->sgl, tot_len, + offset, &total_nents, + &mlli_p); else /*DMA_BUFF_TYPE*/ - rc = cc_render_buff_to_mlli(dev, - sg_data->entry[i].buffer_dma, - sg_data->total_data_len[i], - &total_nents, &mlli_p); + rc = cc_render_buff_to_mlli(dev, entry->buffer_dma, + tot_len, &total_nents, + &mlli_p); if (rc != 0) return rc; From patchwork Thu Nov 9 09:16:13 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: 118417 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6345872qgn; Thu, 9 Nov 2017 01:16:57 -0800 (PST) X-Google-Smtp-Source: ABhQp+Rr6iIPHxzID9ZgySVeXHl/drZu6buuc6oiV1sKUf1A1+AslegLBdEwOYZyOqOAXK8RZDfs X-Received: by 10.99.117.7 with SMTP id q7mr3287951pgc.339.1510219017586; Thu, 09 Nov 2017 01:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510219017; cv=none; d=google.com; s=arc-20160816; b=UJn24h3hwgeFGxt0yhMxuTwSRH0asCOmIhhFbome3ZSXpvQsv6gXrpvww26FQuIyxu Um4fpzI5IEPJwnGyVdq1Y4ZXHg6V5+i6DKV/YPtizRFktnbp5wG52V0BaMkOIi2GS5X9 NzZXOShZ4SodJiRil9xAU3BVYU72ouZSUokXbmT/ka/1NHsvVdXXq0PzNbhrCiiLeazN jwAmcVu50qhEAkoYPgF4l0OJMCmf/xYU2+4CYsKi9Ak/2IXs5uvR9idBWRdxQvi5Sedn a5hzuUJIXmTMvUvcZ9pZA5c0nw0YQRFgduf9b3lclEAcevRedzO/GPfTBm2GCctezy61 MhdA== 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=bPI0fhsEP/q0k+zOgZTgfc0CCZndGU4i99Rx5kLl0qI=; b=yd+gn2ixXHzqMVrly5ob3Zlz1Fx+eg8CIwTNV+uRwdFos3qI1boAnQbwTtEa0TQLf+ g/56QQNaxaWT+QC8Mq7CzcxWYmfVXUvHC2jR1WeweyMeG0JpPgeGlT3EAe5buR1Hp+mi Zr/XMGvfyNs4tFDsnVT7HZUqxXe15u8PElQgEy12QWazC/aR8THwiYKbg+R9fbsbwT5V oBa+GyqkB1y3SCsWDszwxg3zJ8rp38MCFYE6hAAJKlmccoLYnrw1EJ0TQff7YgT2rlie LN5g2vXyUbXCr/JBPsAokIyaaCdPOSv52Kj/3IIILbHkC73Ng32tGvfQk/pIvgelhOG/ 37+Q== 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 h10si4787642pgq.545.2017.11.09.01.16.57; Thu, 09 Nov 2017 01:16:57 -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 S1754065AbdKIJQy (ORCPT + 25 others); Thu, 9 Nov 2017 04:16:54 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43626 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753960AbdKIJLY (ORCPT ); Thu, 9 Nov 2017 04:11:24 -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 8C4171435; Thu, 9 Nov 2017 01:11:24 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2E3113F246; Thu, 9 Nov 2017 01:11:21 -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 v2 05/10] staging: ccree: fold common code into function Date: Thu, 9 Nov 2017 09:16:13 +0000 Message-Id: <1510218980-3549-6-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Fold common code copying MAC to/from a temp. buffer into an inline function instead of keeping multiple open coded versions of same. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 89 ++++++++++++++-------------------- 1 file changed, 37 insertions(+), 52 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index b3ca249..48c0b02 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -65,6 +65,27 @@ struct buffer_array { }; /** + * cc_copy_mac() - Copy MAC to temporary location + * + * @dev: device object + * @req: aead request object + * @dir: [IN] copy from/to sgl + */ +static inline void cc_copy_mac(struct device *dev, struct aead_request *req, + enum ssi_sg_cpy_direct dir) +{ + struct aead_req_ctx *areq_ctx = aead_request_ctx(req); + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + u32 skip = req->assoclen + req->cryptlen; + + if (areq_ctx->is_gcm4543) + skip += crypto_aead_ivsize(tfm); + + cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src, + (skip - areq_ctx->req_authsize), skip, dir); +} + +/** * cc_get_sgl_nents() - Get scatterlist number of entries. * * @sg_list: SG list @@ -670,19 +691,11 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) if (drvdata->coherent && (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) && likely(req->src == req->dst)) { - u32 size_to_skip = req->assoclen; - - if (areq_ctx->is_gcm4543) - size_to_skip += crypto_aead_ivsize(tfm); - /* copy mac to a temporary location to deal with possible + /* copy back mac from temporary location to deal with possible * data memory overriding that caused by cache coherence problem. */ - cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src, - (size_to_skip + req->cryptlen - - areq_ctx->req_authsize), - (size_to_skip + req->cryptlen), - SSI_SG_FROM_BUF); + cc_copy_mac(dev, req, SSI_SG_FROM_BUF); } } @@ -918,7 +931,6 @@ static inline int cc_prepare_aead_data_mlli( enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type; unsigned int authsize = areq_ctx->req_authsize; int rc = 0, icv_nents; - struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct device *dev = drvdata_to_dev(drvdata); if (likely(req->src == req->dst)) { @@ -943,24 +955,14 @@ static inline int cc_prepare_aead_data_mlli( * MAC verification upon request completion */ if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) { - if (!drvdata->coherent) { /* In coherent platforms (e.g. ACP) * already copying ICV for any * INPLACE-DECRYPT operation, hence * we must neglect this code. */ - u32 skip = req->assoclen; - - if (areq_ctx->is_gcm4543) - skip += crypto_aead_ivsize(tfm); - - cc_copy_sg_portion(dev, - areq_ctx->backup_mac, - req->src, - (skip + req->cryptlen - areq_ctx->req_authsize), - (skip + req->cryptlen), - SSI_SG_TO_BUF); - } + if (!drvdata->coherent) + cc_copy_mac(dev, req, SSI_SG_TO_BUF); + areq_ctx->icv_virt_addr = areq_ctx->backup_mac; } else { areq_ctx->icv_virt_addr = areq_ctx->mac_buf; @@ -996,22 +998,14 @@ static inline int cc_prepare_aead_data_mlli( goto prepare_data_mlli_exit; } + /* Backup happens only when ICV is fragmented, ICV + * verification is made by CPU compare in order to simplify + * MAC verification upon request completion + */ if (unlikely(areq_ctx->is_icv_fragmented)) { - /* Backup happens only when ICV is fragmented, ICV - * verification is made by CPU compare in order to simplify - * MAC verification upon request completion - */ - u32 size_to_skip = req->assoclen; - - if (areq_ctx->is_gcm4543) - size_to_skip += crypto_aead_ivsize(tfm); - - cc_copy_sg_portion(dev, areq_ctx->backup_mac, - req->src, - (size_to_skip + req->cryptlen - areq_ctx->req_authsize), - (size_to_skip + req->cryptlen), - SSI_SG_TO_BUF); + cc_copy_mac(dev, req, SSI_SG_TO_BUF); areq_ctx->icv_virt_addr = areq_ctx->backup_mac; + } else { /* Contig. ICV */ /*Should hanlde if the sg is not contig.*/ areq_ctx->icv_dma_addr = sg_dma_address( @@ -1249,22 +1243,13 @@ int cc_map_aead_request( mlli_params->curr_pool = NULL; sg_data.num_of_buffers = 0; + /* copy mac to a temporary location to deal with possible + * data memory overriding that caused by cache coherence problem. + */ if (drvdata->coherent && (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) && - likely(req->src == req->dst)) { - u32 size_to_skip = req->assoclen; - - if (is_gcm4543) - size_to_skip += crypto_aead_ivsize(tfm); - - /* copy mac to a temporary location to deal with possible - * data memory overriding that caused by cache coherence problem. - */ - cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src, - (size_to_skip + req->cryptlen - areq_ctx->req_authsize), - (size_to_skip + req->cryptlen), - SSI_SG_TO_BUF); - } + likely(req->src == req->dst)) + cc_copy_mac(dev, req, SSI_SG_TO_BUF); /* cacluate the size for cipher remove ICV in decrypt*/ areq_ctx->cryptlen = (areq_ctx->gen_ctx.op_type == From patchwork Thu Nov 9 09:16:15 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: 118405 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6341196qgn; Thu, 9 Nov 2017 01:11:41 -0800 (PST) X-Google-Smtp-Source: ABhQp+SSDDReY4g9kbFcyTeGclId/ypMsYNJkGAwUy49UOTDuTkSAfcaiAUoJTVNOOFShN17GgRD X-Received: by 10.101.86.196 with SMTP id w4mr3300207pgs.335.1510218701373; Thu, 09 Nov 2017 01:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218701; cv=none; d=google.com; s=arc-20160816; b=d3ihGuMLDAHJkGOF/BbrqMlsmPYBP+p5L+QChC9zr5umCJ4D8GtFlQWMhHJtkH6JIv bi6M6KFiAtG2DV+hal9FdO+DOwg+j62/N5C64nGetNznsF89U8dQNJ8vDmrX/mN8kh49 we8Zf/5SgZyh3EjCwpGvOE+v2akCA2qIY1kC2FRdlYRE0Mz8TnbnX1hv5jeUXymH3QKx YGlWfT8sPf6qWOMaQdz+mpxX0ZfaaD2MmeYpmlxze0UclbNtMFDS+soY1gvkXG6WgMeq htp5wH5+x/+o5fQ06xSmerDm3OM7QY6l0p0o4TkmXFb1Z1leY8NqPIDBPY8J6djBYXni LasQ== 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=AKB/idqUUNQSnpmMr6flJwtjxPrmSnlgoURDDkEtzlQ=; b=lpArKe2fTwcnUTpVSQmBNoKjh1rce1zVzdQr63Skkspe9d/fu650UkyMRi/g4CFojA LHruwV+7tO/bR6syACtUrstevClkb3zEeYrbo5URwjP1Atpad2UXaUu97maXBjX0K1vm JMizxLpUBtXR88NpOUvYCVp+uv6hCyeJHflSuZYr66DmlzdmHlQj+lq5OXFzfWS7Vgnq nBXw0DBiAcOuKGrMVkiKu/uZmn/0gKZGDevPnyCal/qlWnQvDPAAvL9M9bHDl8eTQ2Ba D/YiVJW475VUvBHr79GbAGqIQyB/T5Z+9OIQlQN66YI1iDmNKfXM/2IU83elVd/Wjjmx gyYA== 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 u2si5984211plm.60.2017.11.09.01.11.41; Thu, 09 Nov 2017 01:11:41 -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 S1754016AbdKIJLi (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:38 -0500 Received: from foss.arm.com ([217.140.101.70]:43648 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753997AbdKIJLd (ORCPT ); Thu, 9 Nov 2017 04:11:33 -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 707421435; Thu, 9 Nov 2017 01:11:33 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA5603F246; Thu, 9 Nov 2017 01:11:31 -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 v2 07/10] staging: ccree: remove unneeded cast Date: Thu, 9 Nov 2017 09:16:15 +0000 Message-Id: <1510218980-3549-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Remove unneeded cast of the return value of dev_get_drvdata() to struct ssi_drvdata * for better readability. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_pm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index d60143c..d3e9382 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -36,8 +36,7 @@ int cc_pm_suspend(struct device *dev) { - struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(dev); + struct ssi_drvdata *drvdata = dev_get_drvdata(dev); int rc; dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); @@ -56,8 +55,7 @@ int cc_pm_suspend(struct device *dev) int cc_pm_resume(struct device *dev) { int rc; - struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(dev); + struct ssi_drvdata *drvdata = dev_get_drvdata(dev); dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n"); cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); @@ -90,8 +88,7 @@ int cc_pm_resume(struct device *dev) int cc_pm_get(struct device *dev) { int rc = 0; - struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(dev); + struct ssi_drvdata *drvdata = dev_get_drvdata(dev); if (cc_req_queue_suspended(drvdata)) rc = pm_runtime_get_sync(dev); @@ -104,8 +101,7 @@ int cc_pm_get(struct device *dev) int cc_pm_put_suspend(struct device *dev) { int rc = 0; - struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(dev); + struct ssi_drvdata *drvdata = dev_get_drvdata(dev); if (!cc_req_queue_suspended(drvdata)) { pm_runtime_mark_last_busy(dev); From patchwork Thu Nov 9 09:16:16 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: 118408 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6341992qgn; Thu, 9 Nov 2017 01:12:38 -0800 (PST) X-Google-Smtp-Source: ABhQp+SqQkStx+GTxL7OSGUia2a+luN2mwtiBX+iup3HZiBEUjpapbAPSM/n08LxwiKZgOReFs1n X-Received: by 10.84.217.81 with SMTP id e17mr3228946plj.345.1510218758129; Thu, 09 Nov 2017 01:12:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218758; cv=none; d=google.com; s=arc-20160816; b=yTOn1EDIwxc/Ub3jPvQ4Yq6pGeIYeEch2Vk2kb+3z+Yznr3LMhjxBlOKvYOdi13I5M KUER/TUzc9lie9SwIi4MONBY0gR4Buy2I2xtp2NZckTTgCueGVfk3lCa6w7LC0/HDzFW v4+DF0f/xrNntGrnD8G3PG3vQmvN/t/Iw5SuyYlpwwmz0iymqq1pHkXUQu95vh4TzC5E /VH1ci7BMdmd+2f6jt4P5OsDPmBhRq/3aX5BHwCrFO5MukLhtJpKFumvdDjTy5QMj5/R j/RVo2r+EErT6+G5Uhdd7HqgunZIDzTGAd3qQpN+ix+lLYDKQeFoWNAkz9UTfXOX02Mi 3VGw== 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=7CcccLpDHQKwO3cGjw7+P35BDZDaRgu4hZQ/9LRD/4w=; b=iFOS82dyNZj1oTxhFyovevEToBOZ0Dq5wJ5vCd9Y50vKEek0RKiSIrTuCUa+/tyaPJ MqzD992qw6fSTJvfbJtYGv7DW9Q3cXxGMLF7GFHyjBVkuOWR3M/hi/WdMY3QJh5Nouki hY8U2QIOz3KzFz1tp8WlTIrSCo5opw/EubGUT5e5exspFT0JNm1F4iT5kE10+rDXvyiF xZLCk17QdehFmqur5A0vsCQB2lqk7u0+Dk1Cwgfzx1+bk2u3jt/1O5jcoN4XN5Eovjb9 le6MUueVWSaVEVHMP6gYC3uy1dPvc6By1jwBKZNX8xKOvQUfYuW120AIP8dXbSYQ5Vzy Ituw== 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 t3si6067165plm.311.2017.11.09.01.12.37; Thu, 09 Nov 2017 01:12:38 -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 S1754037AbdKIJLr (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:47 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43656 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753997AbdKIJLj (ORCPT ); Thu, 9 Nov 2017 04:11:39 -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 A38C41435; Thu, 9 Nov 2017 01:11:39 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 501E63F246; Thu, 9 Nov 2017 01:11:36 -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 v2 08/10] staging: ccree: remove compare to none zero Date: Thu, 9 Nov 2017 09:16:16 +0000 Message-Id: <1510218980-3549-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 The driver was full of code checking "if (x != 0)". Replace by "if (x)" for better readability. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 28 +++++------ drivers/staging/ccree/ssi_buffer_mgr.c | 74 ++++++++++++++--------------- drivers/staging/ccree/ssi_cipher.c | 14 +++--- drivers/staging/ccree/ssi_driver.c | 34 +++++++------- drivers/staging/ccree/ssi_hash.c | 82 ++++++++++++++++----------------- drivers/staging/ccree/ssi_ivgen.c | 2 +- drivers/staging/ccree/ssi_pm.c | 8 ++-- drivers/staging/ccree/ssi_request_mgr.c | 12 ++--- drivers/staging/ccree/ssi_sram_mgr.c | 2 +- 9 files changed, 128 insertions(+), 128 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index a8e1371..e036168 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -539,10 +539,10 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl } rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (unlikely(rc != 0)) + if (unlikely(rc)) dev_err(dev, "send_request() failed (rc=%d)\n", rc); - if (likely(key_dma_addr != 0)) + if (likely(key_dma_addr)) dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE); return rc; @@ -598,7 +598,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) } rc = validate_keys_sizes(ctx); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto badkey; /* STAT_PHASE_1: Copy key to ctx */ @@ -611,7 +611,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) memcpy(ctx->auth_state.xcbc.xcbc_keys, key, ctx->auth_keylen); } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC */ rc = ssi_get_plain_hmac_key(tfm, key, ctx->auth_keylen); - if (rc != 0) + if (rc) goto badkey; } @@ -637,7 +637,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) if (seq_len > 0) { /* For CCM there is no sequence to setup the key */ rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 0); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto setkey_error; } @@ -1520,7 +1520,7 @@ static inline int ssi_aead_ccm( } /* process the cipher */ - if (req_ctx->cryptlen != 0) + if (req_ctx->cryptlen) ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, &idx); /* Read temporal MAC */ @@ -1602,7 +1602,7 @@ static int config_ccm_adata(struct aead_request *req) *b0 |= 64; /* Enable bit 6 if Adata exists. */ rc = set_msg_len(b0 + 16 - l, cryptlen, l); /* Write L'. */ - if (rc != 0) { + if (rc) { dev_err(dev, "message len overflow detected"); return rc; } @@ -1739,7 +1739,7 @@ static inline void ssi_aead_gcm_setup_gctr_desc( set_flow_mode(&desc[idx], S_DIN_to_AES); idx++; - if ((req_ctx->cryptlen != 0) && (!req_ctx->plaintext_authenticate_only)) { + if (req_ctx->cryptlen && !req_ctx->plaintext_authenticate_only) { /* load AES/CTR initial CTR value inc by 2*/ hw_desc_init(&desc[idx]); set_cipher_mode(&desc[idx], DRV_CIPHER_GCTR); @@ -1854,7 +1854,7 @@ static inline int ssi_aead_gcm( ssi_aead_create_assoc_desc(req, DIN_HASH, desc, seq_size); ssi_aead_gcm_setup_gctr_desc(req, desc, seq_size); /* process(gctr+ghash) */ - if (req_ctx->cryptlen != 0) + if (req_ctx->cryptlen) ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, seq_size); ssi_aead_process_gcm_result_desc(req, desc, seq_size); @@ -1984,7 +1984,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction /* STAT_PHASE_0: Init and sanity checks */ /* Check data length according to mode */ - if (unlikely(validate_data_size(ctx, direct, req) != 0)) { + if (unlikely(validate_data_size(ctx, direct, req))) { dev_err(dev, "Unsupported crypt/assoc len %d/%d.\n", req->cryptlen, req->assoclen); crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN); @@ -2031,7 +2031,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction #if SSI_CC_HAS_AES_CCM if (ctx->cipher_mode == DRV_CIPHER_CCM) { rc = config_ccm_adata(req); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_dbg(dev, "config_ccm_adata() returned with a failure %d!", rc); goto exit; @@ -2046,7 +2046,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction #if SSI_CC_HAS_AES_GCM if (ctx->cipher_mode == DRV_CIPHER_GCTR) { rc = config_gcm_context(req); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_dbg(dev, "config_gcm_context() returned with a failure %d!", rc); goto exit; @@ -2055,7 +2055,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction #endif /*SSI_CC_HAS_AES_GCM*/ rc = cc_map_aead_request(ctx->drvdata, req); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "map_request() failed\n"); goto exit; } @@ -2774,7 +2774,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) } t_alg->drvdata = drvdata; rc = crypto_register_aead(&t_alg->aead_alg); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "%s alg registration failed\n", t_alg->aead_alg.base.cra_driver_name); goto fail2; diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 48c0b02..29ef046 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -98,8 +98,8 @@ static unsigned int cc_get_sgl_nents( { unsigned int nents = 0; - while (nbytes != 0) { - if (sg_list->length != 0) { + while (nbytes) { + if (sg_list->length) { nents++; /* get the number of bytes in the last entry */ *lbytes = nbytes; @@ -203,7 +203,7 @@ static inline int cc_render_sg_to_mlli( u32 *mlli_entry_p = *mlli_entry_pp; s32 rc = 0; - for ( ; (curr_sgl) && (sgl_data_len != 0); + for ( ; (curr_sgl && sgl_data_len); curr_sgl = sg_next(curr_sgl)) { u32 entry_data_len = (sgl_data_len > sg_dma_len(curr_sgl) - sgl_offset) ? @@ -213,7 +213,7 @@ static inline int cc_render_sg_to_mlli( rc = cc_render_buff_to_mlli(dev, sg_dma_address(curr_sgl) + sgl_offset, entry_data_len, curr_nents, &mlli_entry_p); - if (rc != 0) + if (rc) return rc; sgl_offset = 0; @@ -258,7 +258,7 @@ static int cc_generate_mlli( rc = cc_render_buff_to_mlli(dev, entry->buffer_dma, tot_len, &total_nents, &mlli_p); - if (rc != 0) + if (rc) return rc; /* set last bit in the current table */ @@ -480,7 +480,7 @@ void cc_unmap_blkcipher_request( { struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx; - if (likely(req_ctx->gen_ctx.iv_dma_addr != 0)) { + if (likely(req_ctx->gen_ctx.iv_dma_addr)) { dev_dbg(dev, "Unmapped iv: iv_dma_addr=%pad iv_size=%u\n", &req_ctx->gen_ctx.iv_dma_addr, ivsize); dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr, @@ -527,7 +527,7 @@ int cc_map_blkcipher_request( sg_data.num_of_buffers = 0; /* Map IV buffer */ - if (likely(ivsize != 0)) { + if (likely(ivsize)) { dump_byte_array("iv", (u8 *)info, ivsize); req_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, (void *)info, @@ -549,7 +549,7 @@ int cc_map_blkcipher_request( /* Map the src SGL */ rc = cc_map_sg(dev, src, nbytes, DMA_BIDIRECTIONAL, &req_ctx->in_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, &mapped_nents); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { rc = -ENOMEM; goto ablkcipher_exit; } @@ -589,7 +589,7 @@ int cc_map_blkcipher_request( if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; rc = cc_generate_mlli(dev, &sg_data, mlli_params); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto ablkcipher_exit; } @@ -613,29 +613,29 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) bool chained; u32 size_to_unmap = 0; - if (areq_ctx->mac_buf_dma_addr != 0) { + if (areq_ctx->mac_buf_dma_addr) { dma_unmap_single(dev, areq_ctx->mac_buf_dma_addr, MAX_MAC_SIZE, DMA_BIDIRECTIONAL); } #if SSI_CC_HAS_AES_GCM if (areq_ctx->cipher_mode == DRV_CIPHER_GCTR) { - if (areq_ctx->hkey_dma_addr != 0) { + if (areq_ctx->hkey_dma_addr) { dma_unmap_single(dev, areq_ctx->hkey_dma_addr, AES_BLOCK_SIZE, DMA_BIDIRECTIONAL); } - if (areq_ctx->gcm_block_len_dma_addr != 0) { + if (areq_ctx->gcm_block_len_dma_addr) { dma_unmap_single(dev, areq_ctx->gcm_block_len_dma_addr, AES_BLOCK_SIZE, DMA_TO_DEVICE); } - if (areq_ctx->gcm_iv_inc1_dma_addr != 0) { + if (areq_ctx->gcm_iv_inc1_dma_addr) { dma_unmap_single(dev, areq_ctx->gcm_iv_inc1_dma_addr, AES_BLOCK_SIZE, DMA_TO_DEVICE); } - if (areq_ctx->gcm_iv_inc2_dma_addr != 0) { + if (areq_ctx->gcm_iv_inc2_dma_addr) { dma_unmap_single(dev, areq_ctx->gcm_iv_inc2_dma_addr, AES_BLOCK_SIZE, DMA_TO_DEVICE); } @@ -643,14 +643,14 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) #endif if (areq_ctx->ccm_hdr_size != ccm_header_size_null) { - if (areq_ctx->ccm_iv0_dma_addr != 0) { + if (areq_ctx->ccm_iv0_dma_addr) { dma_unmap_single(dev, areq_ctx->ccm_iv0_dma_addr, AES_BLOCK_SIZE, DMA_TO_DEVICE); } dma_unmap_sg(dev, &areq_ctx->ccm_adata_sg, 1, DMA_TO_DEVICE); } - if (areq_ctx->gen_ctx.iv_dma_addr != 0) { + if (areq_ctx->gen_ctx.iv_dma_addr) { dma_unmap_single(dev, areq_ctx->gen_ctx.iv_dma_addr, hw_iv_size, DMA_BIDIRECTIONAL); } @@ -1125,7 +1125,7 @@ static inline int cc_aead_chain_data( &areq_ctx->dst.nents, LLI_MAX_NUM_OF_DATA_ENTRIES, &dst_last_bytes, &dst_mapped_nents); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { rc = -ENOMEM; goto chain_data_exit; } @@ -1284,7 +1284,7 @@ int cc_map_aead_request( } if (ssi_aead_handle_config_buf(dev, areq_ctx, areq_ctx->ccm_config, &sg_data, - req->assoclen) != 0) { + req->assoclen)) { rc = -ENOMEM; goto aead_map_failure; } @@ -1353,7 +1353,7 @@ int cc_map_aead_request( (LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES + LLI_MAX_NUM_OF_DATA_ENTRIES), &dummy, &mapped_nents); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { rc = -ENOMEM; goto aead_map_failure; } @@ -1366,13 +1366,13 @@ int cc_map_aead_request( * Note: IV is contg. buffer (not an SGL) */ rc = cc_aead_chain_assoc(drvdata, req, &sg_data, true, false); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; rc = cc_aead_chain_iv(drvdata, req, &sg_data, true, false); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; rc = cc_aead_chain_data(drvdata, req, &sg_data, true, false); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; } else { /* DOUBLE-PASS flow */ /* @@ -1396,13 +1396,13 @@ int cc_map_aead_request( * (4) MLLI for dst */ rc = cc_aead_chain_assoc(drvdata, req, &sg_data, false, true); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; rc = cc_aead_chain_iv(drvdata, req, &sg_data, false, true); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; rc = cc_aead_chain_data(drvdata, req, &sg_data, true, true); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; } @@ -1412,7 +1412,7 @@ int cc_map_aead_request( (areq_ctx->data_buff_type == SSI_DMA_BUF_MLLI))) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; rc = cc_generate_mlli(dev, &sg_data, mlli_params); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto aead_map_failure; cc_update_aead_mlli_nents(drvdata, req); @@ -1459,9 +1459,9 @@ int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, /*TODO: copy data in case that buffer is enough for operation */ /* map the previous buffer */ - if (*curr_buff_cnt != 0) { + if (*curr_buff_cnt) { if (ssi_ahash_handle_curr_buf(dev, areq_ctx, curr_buff, - *curr_buff_cnt, &sg_data) != 0) { + *curr_buff_cnt, &sg_data)) { return -ENOMEM; } } @@ -1491,7 +1491,7 @@ int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, /* add the src data to the sg_data */ cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes, 0, true, &areq_ctx->mlli_nents); - if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params) != 0)) { + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) { goto fail_unmap_din; } } @@ -1505,7 +1505,7 @@ int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, dma_unmap_sg(dev, src, areq_ctx->in_nents, DMA_TO_DEVICE); unmap_curr_buff: - if (*curr_buff_cnt != 0) + if (*curr_buff_cnt) dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); return -ENOMEM; @@ -1563,7 +1563,7 @@ int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, *next_buff_cnt, update_data_len); /* Copy the new residue to next buffer */ - if (*next_buff_cnt != 0) { + if (*next_buff_cnt) { dev_dbg(dev, " handle residue: next buff %pK skip data %u residue %u\n", next_buff, (update_data_len - *curr_buff_cnt), *next_buff_cnt); @@ -1574,9 +1574,9 @@ int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, swap_index = 1; } - if (*curr_buff_cnt != 0) { + if (*curr_buff_cnt) { if (ssi_ahash_handle_curr_buf(dev, areq_ctx, curr_buff, - *curr_buff_cnt, &sg_data) != 0) { + *curr_buff_cnt, &sg_data)) { return -ENOMEM; } /* change the buffer index for next operation */ @@ -1610,7 +1610,7 @@ int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, (update_data_len - *curr_buff_cnt), 0, true, &areq_ctx->mlli_nents); - if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params) != 0)) { + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) { goto fail_unmap_din; } } @@ -1622,7 +1622,7 @@ int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, dma_unmap_sg(dev, src, areq_ctx->in_nents, DMA_TO_DEVICE); unmap_curr_buff: - if (*curr_buff_cnt != 0) + if (*curr_buff_cnt) dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); return -ENOMEM; @@ -1647,14 +1647,14 @@ void cc_unmap_hash_request(struct device *dev, void *ctx, areq_ctx->mlli_params.mlli_dma_addr); } - if ((src) && likely(areq_ctx->in_nents != 0)) { + if ((src) && likely(areq_ctx->in_nents)) { dev_dbg(dev, "Unmapped sg src: virt=%pK dma=%pad len=0x%X\n", sg_virt(src), &sg_dma_address(src), sg_dma_len(src)); dma_unmap_sg(dev, src, areq_ctx->in_nents, DMA_TO_DEVICE); } - if (*prev_len != 0) { + if (*prev_len) { dev_dbg(dev, "Unmapped buffer: areq_ctx->buff_sg=%pK dma=%pad len 0x%X\n", sg_virt(areq_ctx->buff_sg), &sg_dma_address(areq_ctx->buff_sg), diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 721acf4..4d05b4a 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -311,7 +311,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, keylen -= 1; #endif /*SSI_CC_HAS_MULTI2*/ - if (unlikely(validate_keys_sizes(ctx_p, keylen) != 0)) { + if (unlikely(validate_keys_sizes(ctx_p, keylen))) { dev_err(dev, "Unsupported key size %d.\n", keylen); crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; @@ -365,13 +365,13 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, } } if ((ctx_p->cipher_mode == DRV_CIPHER_XTS) && - xts_check_key(tfm, key, keylen) != 0) { + xts_check_key(tfm, key, keylen)) { dev_dbg(dev, "weak XTS key"); return -EINVAL; } if ((ctx_p->flow_mode == S_DIN_to_DES) && (keylen == DES3_EDE_KEY_SIZE) && - ssi_verify_3des_keys(key, keylen) != 0) { + ssi_verify_3des_keys(key, keylen)) { dev_dbg(dev, "weak 3DES key"); return -EINVAL; } @@ -788,7 +788,7 @@ static int ssi_blkcipher_process( rc = cc_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, req_ctx->iv, src, dst); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "map_request() failed\n"); goto exit_process; } @@ -827,7 +827,7 @@ static int ssi_blkcipher_process( } } else { - if (rc != 0) { + if (rc) { cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); } else { @@ -838,7 +838,7 @@ static int ssi_blkcipher_process( } exit_process: - if (cts_restore_flag != 0) + if (cts_restore_flag) ctx_p->cipher_mode = DRV_CIPHER_CBC_CTS; if (rc != -EINPROGRESS) { @@ -1338,7 +1338,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) rc = crypto_register_alg(&t_alg->crypto_alg); dev_dbg(dev, "%s alg registration rc = %x\n", t_alg->crypto_alg.cra_driver_name, rc); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "%s alg registration failed\n", t_alg->crypto_alg.cra_driver_name); kfree(t_alg); diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index b9d1352..7b77f3f 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -111,7 +111,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) drvdata->irq = irr; /* Completion interrupt - most probable */ - if (likely((irr & SSI_COMP_IRQ_MASK) != 0)) { + if (likely((irr & SSI_COMP_IRQ_MASK))) { /* Mask AXI completion interrupt - will be unmasked in Deferred service handler */ cc_iowrite(drvdata, CC_REG(HOST_IMR), imr | SSI_COMP_IRQ_MASK); irr &= ~SSI_COMP_IRQ_MASK; @@ -119,7 +119,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) } #ifdef CC_SUPPORT_FIPS /* TEE FIPS interrupt */ - if (likely((irr & SSI_GPR0_IRQ_MASK) != 0)) { + if (likely((irr & SSI_GPR0_IRQ_MASK))) { /* Mask interrupt - will be unmasked in Deferred service handler */ cc_iowrite(drvdata, CC_REG(HOST_IMR), imr | SSI_GPR0_IRQ_MASK); irr &= ~SSI_GPR0_IRQ_MASK; @@ -127,7 +127,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) } #endif /* AXI error interrupt */ - if (unlikely((irr & SSI_AXI_ERR_IRQ_MASK) != 0)) { + if (unlikely((irr & SSI_AXI_ERR_IRQ_MASK))) { u32 axi_err; /* Read the AXI error ID */ @@ -138,7 +138,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) irr &= ~SSI_AXI_ERR_IRQ_MASK; } - if (unlikely(irr != 0)) { + if (unlikely(irr)) { dev_dbg(dev, "IRR includes unknown cause bits (0x%08X)\n", irr); /* Just warning */ @@ -292,26 +292,26 @@ static int init_cc_resources(struct platform_device *plat_dev) DRV_MODULE_VERSION); rc = init_cc_regs(new_drvdata, true); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "init_cc_regs failed\n"); goto post_clk_err; } #ifdef ENABLE_CC_SYSFS rc = ssi_sysfs_init(&dev->kobj, new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "init_stat_db failed\n"); goto post_regs_err; } #endif rc = ssi_fips_init(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "SSI_FIPS_INIT failed 0x%x\n", rc); goto post_sysfs_err; } rc = ssi_sram_mgr_init(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "ssi_sram_mgr_init failed\n"); goto post_fips_init_err; } @@ -325,45 +325,45 @@ static int init_cc_resources(struct platform_device *plat_dev) } rc = request_mgr_init(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "request_mgr_init failed\n"); goto post_sram_mgr_err; } rc = cc_buffer_mgr_init(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "buffer_mgr_init failed\n"); goto post_req_mgr_err; } rc = cc_pm_init(new_drvdata); - if (unlikely(rc != 0)) { - dev_err(dev, "cc_pm_init failed\n"); + if (unlikely(rc)) { + dev_err(dev, "ssi_power_mgr_init failed\n"); goto post_buf_mgr_err; } rc = ssi_ivgen_init(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "ssi_ivgen_init failed\n"); goto post_power_mgr_err; } /* Allocate crypto algs */ rc = ssi_ablkcipher_alloc(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "ssi_ablkcipher_alloc failed\n"); goto post_ivgen_err; } /* hash must be allocated before aead since hash exports APIs */ rc = ssi_hash_alloc(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "ssi_hash_alloc failed\n"); goto post_cipher_err; } rc = ssi_aead_alloc(new_drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "ssi_aead_alloc failed\n"); goto post_hash_err; } @@ -477,7 +477,7 @@ static int cc7x_probe(struct platform_device *plat_dev) /* Map registers space */ rc = init_cc_resources(plat_dev); - if (rc != 0) + if (rc) return rc; dev_info(dev, "ARM ccree device initialized\n"); diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index eb9cb56..5485372 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -234,7 +234,7 @@ static int ssi_hash_map_request(struct device *dev, set_flow_mode(&desc, BYPASS); rc = send_request(ctx->drvdata, &ssi_req, &desc, 1, 0); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto fail4; } @@ -276,12 +276,12 @@ static int ssi_hash_map_request(struct device *dev, return 0; fail5: - if (state->digest_bytes_len_dma_addr != 0) { + if (state->digest_bytes_len_dma_addr) { dma_unmap_single(dev, state->digest_bytes_len_dma_addr, HASH_LEN_SIZE, DMA_BIDIRECTIONAL); state->digest_bytes_len_dma_addr = 0; } fail4: - if (state->digest_buff_dma_addr != 0) { + if (state->digest_buff_dma_addr) { dma_unmap_single(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); state->digest_buff_dma_addr = 0; } @@ -308,21 +308,21 @@ static void ssi_hash_unmap_request(struct device *dev, struct ahash_req_ctx *state, struct ssi_hash_ctx *ctx) { - if (state->digest_buff_dma_addr != 0) { + if (state->digest_buff_dma_addr) { dma_unmap_single(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", &state->digest_buff_dma_addr); state->digest_buff_dma_addr = 0; } - if (state->digest_bytes_len_dma_addr != 0) { + if (state->digest_bytes_len_dma_addr) { dma_unmap_single(dev, state->digest_bytes_len_dma_addr, HASH_LEN_SIZE, DMA_BIDIRECTIONAL); dev_dbg(dev, "Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n", &state->digest_bytes_len_dma_addr); state->digest_bytes_len_dma_addr = 0; } - if (state->opad_digest_dma_addr != 0) { + if (state->opad_digest_dma_addr) { dma_unmap_single(dev, state->opad_digest_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); dev_dbg(dev, "Unmapped opad-digest: opad_digest_dma_addr=%pad\n", @@ -342,7 +342,7 @@ static void ssi_hash_unmap_result(struct device *dev, struct ahash_req_ctx *state, unsigned int digestsize, u8 *result) { - if (state->digest_result_dma_addr != 0) { + if (state->digest_result_dma_addr) { dma_unmap_single(dev, state->digest_result_dma_addr, digestsize, @@ -419,18 +419,18 @@ static int ssi_hash_digest(struct ahash_req_ctx *state, dev_dbg(dev, "===== %s-digest (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); - if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { + if (unlikely(ssi_hash_map_request(dev, state, ctx))) { dev_err(dev, "map_ahash_source() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, - src, nbytes, 1) != 0)) { + src, nbytes, 1))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -465,7 +465,7 @@ static int ssi_hash_digest(struct ahash_req_ctx *state, NS_BIT); } else { set_din_const(&desc[idx], 0, HASH_LEN_SIZE); - if (likely(nbytes != 0)) + if (likely(nbytes)) set_cipher_config1(&desc[idx], HASH_PADDING_ENABLED); else set_cipher_do(&desc[idx], DO_PAD); @@ -555,7 +555,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (rc != 0) { + if (rc) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); cc_unmap_hash_request(dev, state, src, true); } else { @@ -654,7 +654,7 @@ static int ssi_hash_update(struct ahash_req_ctx *state, } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (rc != 0) { + if (rc) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); cc_unmap_hash_request(dev, state, src, true); } else { @@ -683,11 +683,11 @@ static int ssi_hash_finup(struct ahash_req_ctx *state, nbytes); if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, src, - nbytes, 1) != 0)) { + nbytes, 1))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -787,7 +787,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (rc != 0) { + if (rc) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); @@ -819,12 +819,12 @@ static int ssi_hash_final(struct ahash_req_ctx *state, nbytes); if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, src, - nbytes, 0) != 0)) { + nbytes, 0))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -933,7 +933,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (rc != 0) { + if (rc) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); cc_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); @@ -989,7 +989,7 @@ static int ssi_hash_setkey(void *hash, ctx->key_params.key_dma_addr = 0; ctx->is_hmac = true; - if (keylen != 0) { + if (keylen) { ctx->key_params.key_dma_addr = dma_map_single( dev, (void *)key, keylen, DMA_TO_DEVICE); @@ -1056,7 +1056,7 @@ static int ssi_hash_setkey(void *hash, keylen, NS_BIT, 0); idx++; - if ((blocksize - keylen) != 0) { + if ((blocksize - keylen)) { hw_desc_init(&desc[idx]); set_din_const(&desc[idx], 0, (blocksize - keylen)); @@ -1078,7 +1078,7 @@ static int ssi_hash_setkey(void *hash, } rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto out; } @@ -1218,7 +1218,7 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash, rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); - if (rc != 0) + if (rc) crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN); dma_unmap_single(dev, ctx->key_params.key_dma_addr, @@ -1273,14 +1273,14 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) { struct device *dev = drvdata_to_dev(ctx->drvdata); - if (ctx->digest_buff_dma_addr != 0) { + if (ctx->digest_buff_dma_addr) { dma_unmap_single(dev, ctx->digest_buff_dma_addr, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", &ctx->digest_buff_dma_addr); ctx->digest_buff_dma_addr = 0; } - if (ctx->opad_tmp_keys_dma_addr != 0) { + if (ctx->opad_tmp_keys_dma_addr) { dma_unmap_single(dev, ctx->opad_tmp_keys_dma_addr, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL); @@ -1446,12 +1446,12 @@ static int ssi_mac_final(struct ahash_request *req) dev_dbg(dev, "===== final xcbc reminder (%d) ====\n", rem_cnt); if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, - req->nbytes, 0) != 0)) { + req->nbytes, 0))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -1550,11 +1550,11 @@ static int ssi_mac_finup(struct ahash_request *req) } if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, - req->nbytes, 1) != 0)) { + req->nbytes, 1))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -1617,17 +1617,17 @@ static int ssi_mac_digest(struct ahash_request *req) dev_dbg(dev, "===== -digest mac (%d) ====\n", req->nbytes); - if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { + if (unlikely(ssi_hash_map_request(dev, state, ctx))) { dev_err(dev, "map_ahash_source() failed\n"); return -ENOMEM; } - if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { + if (unlikely(ssi_hash_map_result(dev, state, digestsize))) { dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } if (unlikely(cc_map_hash_request_final(ctx->drvdata, state, req->src, - req->nbytes, 1) != 0)) { + req->nbytes, 1))) { dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -2117,7 +2117,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(digest_len_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(digest_len_init); @@ -2129,7 +2129,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(digest_len_sha512_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(digest_len_sha512_init); @@ -2144,7 +2144,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(md5_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(md5_init); larval_seq_len = 0; @@ -2153,7 +2153,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(sha1_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(sha1_init); larval_seq_len = 0; @@ -2162,7 +2162,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(sha224_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(sha224_init); larval_seq_len = 0; @@ -2171,7 +2171,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ARRAY_SIZE(sha256_init), larval_seq, &larval_seq_len); rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) goto init_digest_const_err; sram_buff_ofs += sizeof(sha256_init); larval_seq_len = 0; @@ -2190,7 +2190,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) sram_buff_ofs += sizeof(u32); } rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "send_request() failed (rc = %d)\n", rc); goto init_digest_const_err; } @@ -2208,7 +2208,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) sram_buff_ofs += sizeof(u32); } rc = send_request_init(drvdata, larval_seq, larval_seq_len); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "send_request() failed (rc = %d)\n", rc); goto init_digest_const_err; } @@ -2257,7 +2257,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) /*must be set before the alg registration as it is being used there*/ rc = ssi_hash_init_sram_digest_consts(drvdata); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "Init digest CONST failed (rc=%d)\n", rc); goto fail; } diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 0d85bce..a33fd76 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -143,7 +143,7 @@ int ssi_ivgen_init_sram_pool(struct ssi_drvdata *drvdata) /* Generate initial pool */ rc = ssi_ivgen_generate_pool(ivgen_ctx, iv_seq, &iv_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) return rc; /* Fire-and-forget */ diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index d3e9382..86d403d 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -42,7 +42,7 @@ int cc_pm_suspend(struct device *dev) dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); rc = cc_suspend_req_queue(drvdata); - if (rc != 0) { + if (rc) { dev_err(dev, "cc_suspend_req_queue (%x)\n", rc); return rc; @@ -67,13 +67,13 @@ int cc_pm_resume(struct device *dev) } rc = init_cc_regs(drvdata, false); - if (rc != 0) { + if (rc) { dev_err(dev, "init_cc_regs (%x)\n", rc); return rc; } rc = cc_resume_req_queue(drvdata); - if (rc != 0) { + if (rc) { dev_err(dev, "cc_resume_req_queue (%x)\n", rc); return rc; } @@ -127,7 +127,7 @@ int cc_pm_init(struct ssi_drvdata *drvdata) pm_runtime_use_autosuspend(dev); /* activate the PM module */ rc = pm_runtime_set_active(dev); - if (rc != 0) + if (rc) return rc; /* enable the PM module*/ pm_runtime_enable(dev); diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index f5d51c1..8fa3fc1 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -73,7 +73,7 @@ void request_mgr_fini(struct ssi_drvdata *drvdata) if (!req_mgr_h) return; /* Not allocated */ - if (req_mgr_h->dummy_comp_buff_dma != 0) { + if (req_mgr_h->dummy_comp_buff_dma) { dma_free_coherent(dev, sizeof(u32), req_mgr_h->dummy_comp_buff, req_mgr_h->dummy_comp_buff_dma); } @@ -275,8 +275,8 @@ int send_request( #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) rc = cc_pm_get(dev); - if (rc != 0) { - dev_err(dev, "cc_pm_get returned %x\n", rc); + if (rc) { + dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc); return rc; } #endif @@ -333,7 +333,7 @@ int send_request( ssi_req->ivgen_dma_addr_len, ssi_req->ivgen_size, iv_seq, &iv_seq_len); - if (unlikely(rc != 0)) { + if (unlikely(rc)) { dev_err(dev, "Failed to generate IV (rc=%d)\n", rc); spin_unlock_bh(&req_mgr_h->hw_lock); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) @@ -412,7 +412,7 @@ int send_request_init( /* Wait for space in HW and SW FIFO. Poll for as much as FIFO_TIMEOUT. */ rc = request_mgr_queues_status_check(drvdata, req_mgr_h, total_seq_len); - if (unlikely(rc != 0)) + if (unlikely(rc)) return rc; set_queue_last_ind(&desc[(len - 1)]); @@ -500,7 +500,7 @@ static void proc_completions(struct ssi_drvdata *drvdata) request_mgr_handle->axi_completed); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) rc = cc_pm_put_suspend(dev); - if (rc != 0) + if (rc) dev_err(dev, "Failed to set runtime suspension %d\n", rc); #endif diff --git a/drivers/staging/ccree/ssi_sram_mgr.c b/drivers/staging/ccree/ssi_sram_mgr.c index 51513248..2263433 100644 --- a/drivers/staging/ccree/ssi_sram_mgr.c +++ b/drivers/staging/ccree/ssi_sram_mgr.c @@ -75,7 +75,7 @@ ssi_sram_addr_t cc_sram_alloc(struct ssi_drvdata *drvdata, u32 size) struct device *dev = drvdata_to_dev(drvdata); ssi_sram_addr_t p; - if (unlikely((size & 0x3) != 0)) { + if (unlikely((size & 0x3))) { dev_err(dev, "Requested buffer size (%u) is not multiple of 4", size); return NULL_SRAM_ADDR; From patchwork Thu Nov 9 09:16:17 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: 118406 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6341366qgn; Thu, 9 Nov 2017 01:11:54 -0800 (PST) X-Google-Smtp-Source: ABhQp+RJwYxnljO7DU2manUrvlYQliVga3bj8iKJNbK+s9pfbHioqTHWfbBzJiFFoC4nGJdJ+Wpv X-Received: by 10.98.220.220 with SMTP id c89mr3404728pfl.167.1510218714417; Thu, 09 Nov 2017 01:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218714; cv=none; d=google.com; s=arc-20160816; b=zNPpJ0xIKo7Q8GPR0iHJbMPdKNQZ70ZIPcD0mh0ZLKpjFlJNnWMOd/GWTNCsZDtI2h y9XkXFaGsRv1AL8POQZdHTvyqTP6btrBKEUzqsDQg1wbolpFY4Ip+TiTrDSSGHj2euHl cAgA2dTBa4Y0e/xDulAEcNQAzkRGgimxckZjsmZ2Ayofdo8+SDMy957G/1cByz6Vwebc k88TZ6S/HYHSDTJsBEtUFnVjl13lrZvSp9xSa2PZv+iywPAOCbX1FJcrxBKb2zXxAVKE bG3P8POe9l7xsB5hIYYNQvsVLWfTUMLXcCqjnQDo8eRort1wKrQVIiCmw34NTo56lGih pnMQ== 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=vpBk+wxjAITPG0aOaIN5uFtUTt9gT3zbc0W5USwE6FA=; b=UV5BOxkWD261iYLLZQsZkev2IJX0wjGR+K2qx0UDX3kfX8C2NL7RfxTiETKSrVxhXz HC396lEZbpKOQyijmEFZ4KCO4xV94Zthx/Liu3DMJjNECYHRTzXvjAPhBXQ07B/lxW92 RcRXue1kNeqGq0ZW9ty2F+3gW14sAkI3wTK/77NLbaJh/2Kl7BY/xC9MDCefiOqongKE V1U+MrvvOCqETSLurM2DsrANikE4FsY7w3Pdv9cwuSaok9y7oDQX32poLOrBEZxt8/qL q7S8qLrcyzgN+bfgQwEA22mv3H31kc+RShDFZMNiA3mBe3xyfL0sznb7v3Hw1KClCAHf v1RA== 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 h66si5643169pgc.386.2017.11.09.01.11.54; Thu, 09 Nov 2017 01:11:54 -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 S1754058AbdKIJLt (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:49 -0500 Received: from foss.arm.com ([217.140.101.70]:43670 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754020AbdKIJLo (ORCPT ); Thu, 9 Nov 2017 04:11:44 -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 1A0DA1435; Thu, 9 Nov 2017 01:11:44 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69A2B3F246; Thu, 9 Nov 2017 01:11:42 -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 v2 09/10] staging: ccree: remove braces for single statement Date: Thu, 9 Nov 2017 09:16:17 +0000 Message-Id: <1510218980-3549-10-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Remove necessary braces for single statement blocks to improve code readabilty. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 29ef046..bfabb5b 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -1491,9 +1491,8 @@ int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, /* add the src data to the sg_data */ cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes, 0, true, &areq_ctx->mlli_nents); - if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) { + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) goto fail_unmap_din; - } } /* change the buffer index for the unmap function */ areq_ctx->buff_index = (areq_ctx->buff_index ^ 1); @@ -1610,9 +1609,8 @@ int cc_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, (update_data_len - *curr_buff_cnt), 0, true, &areq_ctx->mlli_nents); - if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) { + if (unlikely(cc_generate_mlli(dev, &sg_data, mlli_params))) goto fail_unmap_din; - } } areq_ctx->buff_index = (areq_ctx->buff_index ^ swap_index); From patchwork Thu Nov 9 09:16:18 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: 118407 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6341441qgn; Thu, 9 Nov 2017 01:11:58 -0800 (PST) X-Google-Smtp-Source: ABhQp+Qyyn0xrK4UoiBg1KkQQ89yuDtKETINX7lWMkWmakvg+7JBoVPixKBoH0XJweVUdOipX4mO X-Received: by 10.98.200.138 with SMTP id i10mr3475405pfk.222.1510218718479; Thu, 09 Nov 2017 01:11:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218718; cv=none; d=google.com; s=arc-20160816; b=SQbcDiEkISkKf/qR32uWJaXxbrl5dSW2/QtorFTHIYXxNE2sfUVX0WlvF1rY5x1Eew rKWHLWxoAZPe71HU+nou9vOj12pulHyN9CJJ9yPFUHfHXwK5tqX+UBjo812AJ58vm2xj lYM7EbGX4GTgjzSWPu6rI0KkHJ8NwyvEUKLy6u6A55dkw6pk1/upMkyAsNXYD9hend8b cLv8enuQeBNUGQaezBLZSdRq6DI7QrafPS9LCSoII87eLDNx9BuP+pLAFxSuFdb0dV8W 1LF+UKpDZKIo/2pIKa3BYixQ7nKpCgwkhE9EUzXHJ9mSfEpHA/GZ2t9C7/4+nL1KPFBj GcNA== 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=pIK6X86DXSiuGqJo7PtZmdycuEjEmUxn467+T6vtrfk=; b=WeH2WPpaRs/1Sze/x8Qf3Y0RGU4G/fZqXOkoFe5iu43A5BdB3TJwFjHQxKe4Qn7xiY R2WwMjmFOpCORR48fzd1OANu8+6RO9q1tLyFOwsYkKrb3k4ElYIrCBjjE/cSRz/OlWu1 9pQX6qzAeXcDHEXtCCxBBbE3Hs0D0JHqEsnu2odGU1/xOP4QTkPblwBBSe2FLq+R6klW FeosOh3akEiXEXze0ftxU1MMHNErgu2pMgI8xEjD7oz7eH5vzao0hlvEk+kr87f1dcta jBsei35NsQiJoI8ZhAivbvqS3+HycdMb9aF7f4J2YjstiCW+YxEkvknxBDUbXGFz0VYs fhbA== 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 z81si6264247pfl.235.2017.11.09.01.11.58; Thu, 09 Nov 2017 01:11:58 -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 S1754076AbdKIJLz (ORCPT + 25 others); Thu, 9 Nov 2017 04:11:55 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43678 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754020AbdKIJLt (ORCPT ); Thu, 9 Nov 2017 04:11:49 -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 3B2F81435; Thu, 9 Nov 2017 01:11:49 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 921573F246; Thu, 9 Nov 2017 01:11:46 -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 v2 10/10] staging: ccree: remove unused cc_base parameter Date: Thu, 9 Nov 2017 09:16:18 +0000 Message-Id: <1510218980-3549-11-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218980-3549-1-git-send-email-gilad@benyossef.com> References: <1510218980-3549-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 Remove a common parameter named cc_base with the pointer to the mapped command registers which was used by the old register access macros that are not longer in use. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 2 +- drivers/staging/ccree/ssi_cipher.c | 12 +++++------- drivers/staging/ccree/ssi_driver.c | 3 --- drivers/staging/ccree/ssi_driver.h | 2 +- drivers/staging/ccree/ssi_hash.c | 6 +++--- drivers/staging/ccree/ssi_request_mgr.c | 5 ++--- 6 files changed, 12 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index e036168..9e24783 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -225,7 +225,7 @@ static int ssi_aead_init(struct crypto_aead *tfm) return -ENOMEM; } -static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *cc_base) +static void ssi_aead_complete(struct device *dev, void *ssi_req) { struct aead_request *areq = (struct aead_request *)ssi_req; struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 4d05b4a..b5bb97c 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -67,7 +67,7 @@ struct ssi_ablkcipher_ctx { struct crypto_shash *shash_tfm; }; -static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req, void __iomem *cc_base); +static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req); static int validate_keys_sizes(struct ssi_ablkcipher_ctx *ctx_p, u32 size) { @@ -688,8 +688,7 @@ static int ssi_blkcipher_complete(struct device *dev, struct scatterlist *dst, struct scatterlist *src, unsigned int ivsize, - void *areq, - void __iomem *cc_base) + void *areq) { int completion_error = 0; struct ablkcipher_request *req = (struct ablkcipher_request *)areq; @@ -832,8 +831,7 @@ static int ssi_blkcipher_process( dst); } else { rc = ssi_blkcipher_complete(dev, ctx_p, req_ctx, dst, - src, ivsize, NULL, - ctx_p->drvdata->cc_base); + src, ivsize, NULL); } } @@ -849,7 +847,7 @@ static int ssi_blkcipher_process( return rc; } -static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req, void __iomem *cc_base) +static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req) { struct ablkcipher_request *areq = (struct ablkcipher_request *)ssi_req; struct blkcipher_req_ctx *req_ctx = ablkcipher_request_ctx(areq); @@ -858,7 +856,7 @@ static void ssi_ablkcipher_complete(struct device *dev, void *ssi_req, void __io unsigned int ivsize = crypto_ablkcipher_ivsize(tfm); ssi_blkcipher_complete(dev, ctx_p, req_ctx, areq->dst, areq->src, - ivsize, areq, cc_base); + ivsize, areq); } /* Async wrap functions */ diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 7b77f3f..0d5c1a9 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -199,7 +199,6 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; - void __iomem *cc_base = NULL; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -232,8 +231,6 @@ static int init_cc_resources(struct platform_device *plat_dev) dev_dbg(dev, "CC registers mapped from %pa to 0x%p\n", &req_mem_cc_regs->start, new_drvdata->cc_base); - cc_base = new_drvdata->cc_base; - /* Then IRQ */ new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 94c755c..f4967ca 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -100,7 +100,7 @@ #define SSI_MAX_IVGEN_DMA_ADDRESSES 3 struct ssi_crypto_req { - void (*user_cb)(struct device *dev, void *req, void __iomem *cc_base); + void (*user_cb)(struct device *dev, void *req); void *user_arg; dma_addr_t ivgen_dma_addr[SSI_MAX_IVGEN_DMA_ADDRESSES]; /* For the first 'ivgen_dma_addr_len' addresses of this array, diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 5485372..472d3b7 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -357,7 +357,7 @@ static void ssi_hash_unmap_result(struct device *dev, state->digest_result_dma_addr = 0; } -static void ssi_hash_update_complete(struct device *dev, void *ssi_req, void __iomem *cc_base) +static void ssi_hash_update_complete(struct device *dev, void *ssi_req) { struct ahash_request *req = (struct ahash_request *)ssi_req; struct ahash_req_ctx *state = ahash_request_ctx(req); @@ -368,7 +368,7 @@ static void ssi_hash_update_complete(struct device *dev, void *ssi_req, void __i req->base.complete(&req->base, 0); } -static void ssi_hash_digest_complete(struct device *dev, void *ssi_req, void __iomem *cc_base) +static void ssi_hash_digest_complete(struct device *dev, void *ssi_req) { struct ahash_request *req = (struct ahash_request *)ssi_req; struct ahash_req_ctx *state = ahash_request_ctx(req); @@ -384,7 +384,7 @@ static void ssi_hash_digest_complete(struct device *dev, void *ssi_req, void __i req->base.complete(&req->base, 0); } -static void ssi_hash_complete(struct device *dev, void *ssi_req, void __iomem *cc_base) +static void ssi_hash_complete(struct device *dev, void *ssi_req) { struct ahash_request *req = (struct ahash_request *)ssi_req; struct ahash_req_ctx *state = ahash_request_ctx(req); diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 8fa3fc1..e9a09b3 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -189,7 +189,7 @@ static inline void enqueue_seq( * \param dev * \param dx_compl_h The completion event to signal */ -static void request_mgr_complete(struct device *dev, void *dx_compl_h, void __iomem *cc_base) +static void request_mgr_complete(struct device *dev, void *dx_compl_h) { struct completion *this_compl = dx_compl_h; @@ -491,8 +491,7 @@ static void proc_completions(struct ssi_drvdata *drvdata) #endif /* COMPLETION_DELAY */ if (likely(ssi_req->user_cb)) - ssi_req->user_cb(dev, ssi_req->user_arg, - drvdata->cc_base); + ssi_req->user_cb(dev, ssi_req->user_arg); request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); dev_dbg(dev, "Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail);