From patchwork Thu Sep 10 13:21:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7154221 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 518A29F326 for ; Thu, 10 Sep 2015 13:24:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6907B20882 for ; Thu, 10 Sep 2015 13:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B4F220881 for ; Thu, 10 Sep 2015 13:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753511AbbIJNXd (ORCPT ); Thu, 10 Sep 2015 09:23:33 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:35759 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752227AbbIJNVs (ORCPT ); Thu, 10 Sep 2015 09:21:48 -0400 Received: by wicge5 with SMTP id ge5so24932810wic.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=bQHXOnWbA1H+IzSDPy/p18ur+EZPWHqdEviInMyYgsw=; b=nv56JlKhNKRClRZ6SlhuqTZYyhrTp+hQZKnGN6nxMKlIQqVVylQF0P+fwsXeF7Luih 67i/lyqBlNp3Q009ApHLAYEj5D07zWzNSIbSuDHde0WxzXdd7IUX0zBNissUR4T0RJ9n lAvdJiRA24ezDd21tWrIaaTPL7tsolLFAM9KJmW/k3/RYTPXETxM/mtmNJEfC8136Dk9 lsMonB8qcUEJn2YZUo0nMUXGlpei65nlfAk/CZBwcxXjQ195WnY4OY4+IZwyWZbL1DuA a+uCqAyYMjLzpdcVagLxIXO9epxmTQdel8+Ba3AQih7KfzbGtxDmJrS3eVEOIKTEI5Ry dA1g== X-Received: by 10.180.104.68 with SMTP id gc4mr6537528wib.67.1441891306976; Thu, 10 Sep 2015 06:21:46 -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.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Sep 2015 06:21:46 -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 1/7] crypto: bfin: replace sg_count by sg_nents Date: Thu, 10 Sep 2015 15:21:36 +0200 Message-Id: <1441891302-12014-2-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 sg_count function in bfin_crc.c is the same function as sg_nents. Remove the duplicate code and use sg_nents() instead. Signed-off-by: LABBE Corentin --- drivers/crypto/bfin_crc.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index 2f0b333..95b7396 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -96,26 +96,6 @@ struct bfin_crypto_crc_ctx { u32 key; }; - -/* - * derive number of elements in scatterlist - */ -static int sg_count(struct scatterlist *sg_list) -{ - struct scatterlist *sg = sg_list; - int sg_nents = 1; - - if (sg_list == NULL) - return 0; - - while (!sg_is_last(sg)) { - sg_nents++; - sg = sg_next(sg); - } - - return sg_nents; -} - /* * get element in scatter list by given index */ @@ -160,7 +140,7 @@ static int bfin_crypto_crc_init(struct ahash_request *req) } spin_unlock_bh(&crc_list.lock); - if (sg_count(req->src) > CRC_MAX_DMA_DESC) { + if (sg_nents(req->src) > CRC_MAX_DMA_DESC) { dev_dbg(ctx->crc->dev, "init: requested sg list is too big > %d\n", CRC_MAX_DMA_DESC); return -EINVAL; @@ -376,7 +356,8 @@ static int bfin_crypto_crc_handle_queue(struct bfin_crypto_crc *crc, ctx->sg = req->src; /* Chop crc buffer size to multiple of 32 bit */ - nsg = ctx->sg_nents = sg_count(ctx->sg); + nsg = sg_nents(ctx->sg); + ctx->sg_nents = nsg; ctx->sg_buflen = ctx->buflast_len + req->nbytes; ctx->bufnext_len = ctx->sg_buflen % 4; ctx->sg_buflen &= ~0x3;