Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: bfin_crc - replace sg_count by sg_nents

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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

LABBE Corentin and committed by
Herbert Xu
1f6d79d7 be6ec98d

+3 -22
+3 -22
drivers/crypto/bfin_crc.c
··· 96 96 u32 key; 97 97 }; 98 98 99 - 100 - /* 101 - * derive number of elements in scatterlist 102 - */ 103 - static int sg_count(struct scatterlist *sg_list) 104 - { 105 - struct scatterlist *sg = sg_list; 106 - int sg_nents = 1; 107 - 108 - if (sg_list == NULL) 109 - return 0; 110 - 111 - while (!sg_is_last(sg)) { 112 - sg_nents++; 113 - sg = sg_next(sg); 114 - } 115 - 116 - return sg_nents; 117 - } 118 - 119 99 /* 120 100 * get element in scatter list by given index 121 101 */ ··· 140 160 } 141 161 spin_unlock_bh(&crc_list.lock); 142 162 143 - if (sg_count(req->src) > CRC_MAX_DMA_DESC) { 163 + if (sg_nents(req->src) > CRC_MAX_DMA_DESC) { 144 164 dev_dbg(ctx->crc->dev, "init: requested sg list is too big > %d\n", 145 165 CRC_MAX_DMA_DESC); 146 166 return -EINVAL; ··· 356 376 ctx->sg = req->src; 357 377 358 378 /* Chop crc buffer size to multiple of 32 bit */ 359 - nsg = ctx->sg_nents = sg_count(ctx->sg); 379 + nsg = sg_nents(ctx->sg); 380 + ctx->sg_nents = nsg; 360 381 ctx->sg_buflen = ctx->buflast_len + req->nbytes; 361 382 ctx->bufnext_len = ctx->sg_buflen % 4; 362 383 ctx->sg_buflen &= ~0x3;