From patchwork Thu Sep 10 13:21:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7154231 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 800819F326 for ; Thu, 10 Sep 2015 13:24:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A514220882 for ; Thu, 10 Sep 2015 13:24:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B61E820881 for ; Thu, 10 Sep 2015 13:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753166AbbIJNXc (ORCPT ); Thu, 10 Sep 2015 09:23:32 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:37006 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbbIJNVt (ORCPT ); Thu, 10 Sep 2015 09:21:49 -0400 Received: by wicfx3 with SMTP id fx3so23008427wic.0; Thu, 10 Sep 2015 06:21:47 -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=VkAyDgHgPXK7ZX8gR6Tyqs0uWBAflQueIszlSL+0A9U=; b=yuzjeUBmvC4AbQkgA8JiU/NZk9j2CT9BOPg5+jeJ/cceTwaOeCMcCm3WPhJ/Si2gd+ 5qYFYqlrO9F5OH8meY5FI/zdypiAGQIQJ15fbdxZWS4vY2dDnwh/+6XEevGHvihCNXEn obZLXXLRKNqphNyloSjFKfgP8lxRLT+iS7jNBgUhiXramFe/FFjxnrXdqNHkBmAz+V1r OTE0sBnnmbjpB56yay46WBDdF1Y+50u8pB6sSkHbQ08eqMXS0jkdnwMe9MFaJ1uoo7bQ R4UcXbEDysHBiFFkBxamDJFcGxYkeZVWWN3YTRpUM7FoOXhFQWdXiUg7tyIbsGLv+XVX HYbw== X-Received: by 10.180.206.211 with SMTP id lq19mr6617562wic.81.1441891307826; Thu, 10 Sep 2015 06:21:47 -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:47 -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 2/7] crypto: amcc replace get_sg_count by sg_nents_for_len Date: Thu, 10 Sep 2015 15:21:37 +0200 Message-Id: <1441891302-12014-3-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 The get_sg_count function of amcc is the same as sg_nents_for_len from lib/scatterlist.c Signed-off-by: LABBE Corentin --- drivers/crypto/amcc/crypto4xx_core.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 192a8fa..27288fc 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c @@ -740,26 +740,6 @@ void crypto4xx_return_pd(struct crypto4xx_device *dev, pd_uinfo->state = PD_ENTRY_FREE; } -/* - * derive number of elements in scatterlist - * Shamlessly copy from talitos.c - */ -static int get_sg_count(struct scatterlist *sg_list, int nbytes) -{ - struct scatterlist *sg = sg_list; - int sg_nents = 0; - - while (nbytes) { - sg_nents++; - if (sg->length > nbytes) - break; - nbytes -= sg->length; - sg = sg_next(sg); - } - - return sg_nents; -} - static u32 get_next_gd(u32 current) { if (current != PPC4XX_LAST_GD) @@ -800,7 +780,7 @@ u32 crypto4xx_build_pd(struct crypto_async_request *req, u32 gd_idx = 0; /* figure how many gd is needed */ - num_gd = get_sg_count(src, datalen); + num_gd = sg_nents_for_len(src, datalen); if (num_gd == 1) num_gd = 0;