From patchwork Thu Sep 10 13:21:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7154131 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8DBBB9F326 for ; Thu, 10 Sep 2015 13:22:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B58A220882 for ; Thu, 10 Sep 2015 13:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D25A320881 for ; Thu, 10 Sep 2015 13:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900AbbIJNV6 (ORCPT ); Thu, 10 Sep 2015 09:21:58 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:36729 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753166AbbIJNVt (ORCPT ); Thu, 10 Sep 2015 09:21:49 -0400 Received: by wicgb1 with SMTP id gb1so24735173wic.1; Thu, 10 Sep 2015 06:21:48 -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=IRorbBM2EJfe4uKPWd+Rt8G4vaP7j4pAMJNNXTTiktc=; b=Ac9qr/PyvkDxZHRAOqWzcG1jdfyCCcOgwDmsiZZgI3QUN4ZqsluMI/hkgJSg5tfLQw lJszTsfENFPnJRGDjqjjiwMYBNPPYYN9MKJKL7GGafVsmnwcxSAuEiOaAz/k0aJMbAZr vJf5hg3piCFkuI2llqm3QPBRR6pk5UuLUKF2rPZ1+Md+sprWuIhLbXvLyJwijq3zVLfX NIKHKW2/RuCALIorpk8Ix3sfjTyVvErtHun574VCaGWs4l43WU05iOto3jyxvrfx9ZGK e3/DzW+cIRyk1TwaqKWzbIEJvDVNWwttXKhq3bUmkHkdAb2McVliDtnZdG9voD4kS4iF kqXw== X-Received: by 10.180.83.137 with SMTP id q9mr6660060wiy.68.1441891308671; Thu, 10 Sep 2015 06:21:48 -0700 (PDT) Received: from Red.local (ANice-651-1-384-228.w86-205.abo.wanadoo.fr. [86.205.16.228]) by smtp.googlemail.com with ESMTPSA id h6sm9354122wiy.3.2015.09.10.06.21.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Sep 2015 06:21:48 -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 3/7] crypto: sahara replace sahara_sg_length with sg_nents_for_len Date: Thu, 10 Sep 2015 15:21:38 +0200 Message-Id: <1441891302-12014-4-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1441891302-12014-1-git-send-email-clabbe.montjoie@gmail.com> References: <1441891302-12014-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=ham 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 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);