From patchwork Thu Apr 18 13:38:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 162482 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp761515jan; Thu, 18 Apr 2019 06:41:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFH7VTOrqtEEYXou11siGjHNtyue5W4C2vrD8152qQR28S0bikdL76hMFe9n6J5GOpxCrL X-Received: by 2002:a63:6ac1:: with SMTP id f184mr84062409pgc.25.1555594862049; Thu, 18 Apr 2019 06:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555594862; cv=none; d=google.com; s=arc-20160816; b=U3wyo9kY25whDFSOPHY2qGI+KbIbNaHdodZLdN2YvGnud+rFNc9jm4W9aAY7DTUZko YqYGPaMce+MgNubgvbLDDPc7rVeMItvYFYgHGx2DIWlA28UaiKd8x8DQyYkP4kjbWZoX JH0GvvTwCSKgWkS1XtURjdxj9lg5nfWN2azUt54ytOwmRUS3ScfiqhgqcS3bypGSIj83 cIcaslhXO0vpDQ3vgVOFpXf/4Q5Mq3JXZgGimdGVIQlIdBze+81mpt8jeRtzMXGZHXuA xlkzQ/7ly7GQsgq13QyQ8syx9c4S4VUgbp5f1dFkZEQ/OXsVKDck6C2lEkjz5vnRFEV/ z/kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rRLZ35ka4S6HYLOFUga2cteNC4jnNBUZv4M7ZuXY6jM=; b=0gioJFzg8SiJRcxhSr/BccdVAIIm/B4wqc1Tv/Kc7kA46qs6etNzJmpbBDccEmOHjn j3AzSFz4ubfn86I9oeRVqx2IHoLDF4dWrt4WHGJn/EkelWcpi7eSC6yA9YMjX2wjmtGs W6FxYC2XQMrEIyn2dN9LpkEgVIYd1qa3zGQZwSVbrhNqLHDJgiav9c6H0kycBUeLTlpc aocCYIfb6pYU8IltskdOXuL4MzzeYq0X6m8OYEXutV9sYXI+7JgXhJ1ul8Ttu7d4LFiG 1F2BT7JDaaXuGwHW0ncHEsZWUMv0hBihgHx3xa7mawtQ6ewOOXnUK1TH2H14j1Cz1pFa AmHg== 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 a66si2558487pfb.210.2019.04.18.06.41.01; Thu, 18 Apr 2019 06:41:02 -0700 (PDT) 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 S2389105AbfDRNlA (ORCPT + 30 others); Thu, 18 Apr 2019 09:41:00 -0400 Received: from foss.arm.com ([217.140.101.70]:33628 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388582AbfDRNk7 (ORCPT ); Thu, 18 Apr 2019 09:40:59 -0400 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 CE9CD80D; Thu, 18 Apr 2019 06:40:58 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62BBA3F5AF; Thu, 18 Apr 2019 06:40:57 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/35] crypto: ccree: use std api when possible Date: Thu, 18 Apr 2019 16:38:52 +0300 Message-Id: <20190418133913.9122-18-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418133913.9122-1-gilad@benyossef.com> References: <20190418133913.9122-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move to use the std api sg_nents_for_len() when we do not in fact require the extra information about the number of bytes in the last entry provided by the in-driver variant cc_get_sgl_nents(). This also resolves a Coverity warning cause by us not using the output value. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 7c92373df351..ccb0257bdc58 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -133,9 +133,9 @@ void cc_zero_sgl(struct scatterlist *sgl, u32 data_len) void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum cc_sg_cpy_direct direct) { - u32 nents, lbytes; + u32 nents; - nents = cc_get_sgl_nents(dev, sg, end, &lbytes); + nents = sg_nents_for_len(sg, end); sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, (direct == CC_SG_TO_BUF)); } @@ -519,7 +519,6 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) unsigned int hw_iv_size = areq_ctx->hw_iv_size; struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct cc_drvdata *drvdata = dev_get_drvdata(dev); - u32 dummy; u32 size_to_unmap = 0; if (areq_ctx->mac_buf_dma_addr) { @@ -583,15 +582,13 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) if (areq_ctx->is_gcm4543) size_to_unmap += crypto_aead_ivsize(tfm); - dma_unmap_sg(dev, req->src, - cc_get_sgl_nents(dev, req->src, size_to_unmap, &dummy), + dma_unmap_sg(dev, req->src, sg_nents_for_len(req->src, size_to_unmap), DMA_BIDIRECTIONAL); if (req->src != req->dst) { dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", sg_virt(req->dst)); dma_unmap_sg(dev, req->dst, - cc_get_sgl_nents(dev, req->dst, size_to_unmap, - &dummy), + sg_nents_for_len(req->dst, size_to_unmap), DMA_BIDIRECTIONAL); } if (drvdata->coherent && @@ -1429,8 +1426,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, if (total_in_len < block_size) { 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 = - cc_get_sgl_nents(dev, src, nbytes, &dummy); + areq_ctx->in_nents = sg_nents_for_len(src, nbytes); sg_copy_to_buffer(src, areq_ctx->in_nents, &curr_buff[*curr_buff_cnt], nbytes); *curr_buff_cnt += nbytes;