From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
LABBE Corentin <clabbe.montjoie@gmail.com>
Subject: [PATCH v2 1/8] crypto: bfin: replace sg_count by sg_nents
Date: Fri, 18 Sep 2015 14:57:09 +0200 [thread overview]
Message-ID: <1442581036-23789-2-git-send-email-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <1442581036-23789-1-git-send-email-clabbe.montjoie@gmail.com>
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 <clabbe.montjoie@gmail.com>
---
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;
--
2.4.6
next prev parent reply other threads:[~2015-09-18 12:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 12:57 [PATCH v2] crypto: Remove duplicate code of SG helpers functions LABBE Corentin
2015-09-18 12:57 ` LABBE Corentin [this message]
2015-09-18 12:57 ` [PATCH v2 2/8] crypto: amcc replace get_sg_count by sg_nents_for_len LABBE Corentin
2015-09-18 12:57 ` [PATCH v2 3/8] crypto: sahara: replace sahara_sg_length with sg_nents_for_len LABBE Corentin
2015-09-18 12:57 ` [PATCH v2 4/8] s390: replace zfcp_qdio_sbale_count by sg_nents LABBE Corentin
2015-09-30 13:59 ` Steffen Maier
2015-09-18 12:57 ` [PATCH v2 5/8] lib: introduce sg_nents_len_chained LABBE Corentin
2015-09-18 14:01 ` Tom Lendacky
2015-09-18 16:19 ` Tony Battersby
2015-09-18 21:25 ` Tony Battersby
2015-09-21 14:19 ` Herbert Xu
2015-09-21 14:59 ` LABBE Corentin
2015-09-18 12:57 ` [PATCH v2 6/8] crypto: talitos: replace sg_count with sg_nents_len_chained LABBE Corentin
2015-09-18 12:57 ` [PATCH v2 7/8] crypto: qce: replace qce_countsg " LABBE Corentin
2015-09-18 12:57 ` [PATCH v2 8/8] crypto: caam: replace __sg_count " LABBE Corentin
2015-09-21 15:09 ` [PATCH v2] crypto: Remove duplicate code of SG helpers functions Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442581036-23789-2-git-send-email-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®