From patchwork Fri Sep 18 12:57:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7216101 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B1D99BEEC1 for ; Fri, 18 Sep 2015 12:59:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB333208D1 for ; Fri, 18 Sep 2015 12:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 015ED208B8 for ; Fri, 18 Sep 2015 12:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbbIRM6B (ORCPT ); Fri, 18 Sep 2015 08:58:01 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35456 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753705AbbIRM6A (ORCPT ); Fri, 18 Sep 2015 08:58:00 -0400 Received: by wicge5 with SMTP id ge5so31747062wic.0; Fri, 18 Sep 2015 05:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HqhVxsBDSejpM7wON6+kDJHK7R/khHhnbUSxxBE4KDA=; b=M8mWg+iz+xPMY8mRQPYKPCRgludlBJL7/nuKA6Gmy6UhS6h+xfaJUYU/zlDhkeo8xa Ggsmx/iPgrYhdjwyT/M/np/uG/HQjwxa2LiDOtBfAyQZSsXkbviDba7nabuNj1VcMbNV YvZkYMcj4hViusk2+iszsj8Nayv13vF8PSp7LJWjgyey4YB1bcDUPNtOaR7tZOMXA1SV 5iJHEBiPi7GOcQpSoI1mDjgF2pWQ0L2GLVMd+nO+SD9RqhnITdNk49uSiiQeuBrqRX3Y +cAXSG+Nywss+TuS8ffTr4tm1X1Pmsqxqs4uc3VnkMzjcamIrG4pUy/NVVHmgzAuSazU hRVA== X-Received: by 10.194.24.196 with SMTP id w4mr7043273wjf.137.1442581078651; Fri, 18 Sep 2015 05:57:58 -0700 (PDT) Received: from Red.local (ANice-651-1-293-37.w83-201.abo.wanadoo.fr. [83.201.193.37]) by smtp.googlemail.com with ESMTPSA id kb5sm8789638wjc.17.2015.09.18.05.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 05:57:58 -0700 (PDT) From: LABBE Corentin To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, LABBE Corentin Subject: [PATCH v2 3/8] crypto: sahara: replace sahara_sg_length with sg_nents_for_len Date: Fri, 18 Sep 2015 14:57:11 +0200 Message-Id: <1442581036-23789-4-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1442581036-23789-1-git-send-email-clabbe.montjoie@gmail.com> References: <1442581036-23789-1-git-send-email-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sahara_sg_length function of the sahara driver is the same as sg_nents_for_len from lib/scatterlist.c Signed-off-by: LABBE Corentin --- drivers/crypto/sahara.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index 820dc3a..cea2411 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -274,30 +274,6 @@ static u32 sahara_aes_data_link_hdr(struct sahara_dev *dev) SAHARA_HDR_CHA_SKHA | SAHARA_HDR_PARITY_BIT; } -static int sahara_sg_length(struct scatterlist *sg, - unsigned int total) -{ - int sg_nb; - unsigned int len; - struct scatterlist *sg_list; - - sg_nb = 0; - sg_list = sg; - - while (total) { - len = min(sg_list->length, total); - - sg_nb++; - total -= len; - - sg_list = sg_next(sg_list); - if (!sg_list) - total = 0; - } - - return sg_nb; -} - static char *sahara_err_src[16] = { "No error", "Header error", @@ -502,8 +478,8 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev) idx++; } - dev->nb_in_sg = sahara_sg_length(dev->in_sg, dev->total); - dev->nb_out_sg = sahara_sg_length(dev->out_sg, dev->total); + dev->nb_in_sg = sg_nents_for_len(dev->in_sg, dev->total); + dev->nb_out_sg = sg_nents_for_len(dev->out_sg, dev->total); if ((dev->nb_in_sg + dev->nb_out_sg) > SAHARA_MAX_HW_LINK) { dev_err(dev->device, "not enough hw links (%d)\n", dev->nb_in_sg + dev->nb_out_sg); @@ -818,7 +794,7 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev, dev->in_sg = rctx->in_sg; - dev->nb_in_sg = sahara_sg_length(dev->in_sg, rctx->total); + dev->nb_in_sg = sg_nents_for_len(dev->in_sg, rctx->total); if ((dev->nb_in_sg) > SAHARA_MAX_HW_LINK) { dev_err(dev->device, "not enough hw links (%d)\n", dev->nb_in_sg + dev->nb_out_sg);