From patchwork Fri Sep 18 12:57:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7216031 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 9646FBEEC1 for ; Fri, 18 Sep 2015 12:58:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3CF0208D1 for ; Fri, 18 Sep 2015 12:58:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAD79208B8 for ; Fri, 18 Sep 2015 12:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753827AbbIRM62 (ORCPT ); Fri, 18 Sep 2015 08:58:28 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:34446 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753897AbbIRM6Z (ORCPT ); Fri, 18 Sep 2015 08:58:25 -0400 Received: by wicfx3 with SMTP id fx3so63237406wic.1; Fri, 18 Sep 2015 05:58:23 -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=fcAPfNd0P53qUQ1B1Sx3koHA4GPGc7FR3lO38nah9wY=; b=Q616pmA9xOIwPbxcFUfVwgowGVsKt0r+T9R8hpWiDWKWTDrvOjCynKpRrpH0DFndxZ Y93Z340NTVWQTdF2i4ZduAwlXo15gzj0i5l6VUtFah4m8mrYzlQ95LahGEyoo6IKREEX 6dTTdZXedwjlA40llEhX4SDhHN317UJoEknC+EzNodC1/8EPxsvvkfhv/+yLZfaOYOnd Ta3xdFJpTMffRuagCz+BIjxxWYkLEhcVjDSMZE4zAu0IvlCVWKOqvbiWZQgUhRMmWTl+ C+89qmvpObcv9z6oFtzt32NEzXvMb3j7vuDyMAeHBvNESTAhYXq2RZzdApSlNcQnXNJ9 UTeA== X-Received: by 10.194.113.101 with SMTP id ix5mr7708135wjb.66.1442581103539; Fri, 18 Sep 2015 05:58:23 -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.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 05:58:23 -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 6/8] crypto: talitos: replace sg_count with sg_nents_len_chained Date: Fri, 18 Sep 2015 14:57:14 +0200 Message-Id: <1442581036-23789-7-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 talitos driver use a modified version of sg_nents_for_len called sg_count. This function is now availlable in lib/scatterlist.c Replace sg_count by sg_nents_len_chained Signed-off-by: LABBE Corentin --- drivers/crypto/talitos.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 3b20a1b..9156272 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1234,26 +1234,6 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, } /* - * derive number of elements in scatterlist - */ -static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained) -{ - struct scatterlist *sg = sg_list; - int sg_nents = 0; - - *chained = false; - while (nbytes > 0 && sg) { - sg_nents++; - nbytes -= sg->length; - if (!sg_is_last(sg) && (sg + 1)->length == 0) - *chained = true; - sg = sg_next(sg); - } - - return sg_nents; -} - -/* * allocate and map the extended descriptor */ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, @@ -1287,18 +1267,19 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); if (!dst || dst == src) { - src_nents = sg_count(src, assoclen + cryptlen + authsize, - &src_chained); + src_nents = sg_nents_len_chained(src, + assoclen + cryptlen + authsize, + &src_chained); src_nents = (src_nents == 1) ? 0 : src_nents; dst_nents = dst ? src_nents : 0; } else { /* dst && dst != src*/ - src_nents = sg_count(src, assoclen + cryptlen + - (encrypt ? 0 : authsize), - &src_chained); + src_nents = sg_nents_len_chained(src, assoclen + cryptlen + + (encrypt ? 0 : authsize), + &src_chained); src_nents = (src_nents == 1) ? 0 : src_nents; - dst_nents = sg_count(dst, assoclen + cryptlen + - (encrypt ? authsize : 0), - &dst_chained); + dst_nents = sg_nents_len_chained(dst, assoclen + cryptlen + + (encrypt ? authsize : 0), + &dst_chained); dst_nents = (dst_nents == 1) ? 0 : dst_nents; } @@ -1902,7 +1883,8 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { /* Buffer up to one whole block */ sg_copy_to_buffer(areq->src, - sg_count(areq->src, nbytes, &chained), + sg_nents_len_chained(areq->src, + nbytes, &chained), req_ctx->buf + req_ctx->nbuf, nbytes); req_ctx->nbuf += nbytes; return 0; @@ -1935,7 +1917,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) req_ctx->psrc = areq->src; if (to_hash_later) { - int nents = sg_count(areq->src, nbytes, &chained); + int nents = sg_nents_len_chained(areq->src, nbytes, &chained); sg_pcopy_to_buffer(areq->src, nents, req_ctx->bufnext, to_hash_later,