From patchwork Fri Sep 18 12:57:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7216111 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 60045BEEC1 for ; Fri, 18 Sep 2015 13:00:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C35A208D1 for ; Fri, 18 Sep 2015 13:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BEB9208B8 for ; Fri, 18 Sep 2015 13:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753597AbbIRM54 (ORCPT ); Fri, 18 Sep 2015 08:57:56 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:37674 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753580AbbIRM5y (ORCPT ); Fri, 18 Sep 2015 08:57:54 -0400 Received: by wicfx3 with SMTP id fx3so29928766wic.0; Fri, 18 Sep 2015 05:57:53 -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=DKAwyRk2OVW0ginLlDfB4cbApQlIK4l6s+KxOnbjEA5J7Q83MN5uHYinjwgZ5P3xRK /DXDBdKs/K+XYh49GDee7H3pDCNanjTdPCu63uWyy1g6ubrftebGB3kXgwanDI/7SAyW Loxn9h+OOpkpveT+1KfrClLTEbX5Rzg31Cpk04GC0QigXk2b9rCpyWCEQtwbrqYTpN8d AMPA/DZIwaY2i6+M+7cbUU3aEFxYJl+ik2/CmeKFacEe8hNw84WhLNzvQQJjWLs5SOIw NK69C3H/VZuNMI3uCU5fWZqWXHa5juYJESHhdk1TJWjOQc8/ts5b3URhXi7jmZt1q2EZ xpWA== X-Received: by 10.180.223.102 with SMTP id qt6mr15921556wic.11.1442581072972; Fri, 18 Sep 2015 05:57:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 05:57:52 -0700 (PDT) From: LABBE Corentin To: herbert@gondor.apana.org.au, davem@davemloft.net, clabbe.montjoie@gmail.com, dmitry.torokhov@gmail.com, fabio.estevam@freescale.com, wsa@the-dreams.de Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH v2 2/8] crypto: amcc replace get_sg_count by sg_nents_for_len Date: Fri, 18 Sep 2015 14:57:10 +0200 Message-Id: <1442581036-23789-3-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=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;