Skip to contentSkip to conversation

crypto: qce - drop unused scatterlist traversal in qce_ahash_update

PATCH In review Thorsten Blum 3 participants 3 messages Jun 14 – Jul 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qce - drop unused scatterlist traversal in qce_ahash_update

Commit df12ef60c87b ("crypto: qce/sha - Do not modify scatterlist passed along with request") removed the only use of sg_last, rendering the scatterlist traversal useless. Remove it and its local variables.

Also remove the redundant hash_later check, inline the source offset, and assign the number of complete blocks directly to req->nbytes.

---
 drivers/crypto/qce/sha.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)
drivers/crypto/qce/sha.c +5 -26
index 1b37121cbcdc..13a1174d2175 100644
@@ -187,10 +187,8 @@ static int qce_ahash_update(struct ahash_request *req)
 	struct qce_sha_reqctx *rctx = ahash_request_ctx_dma(req);
 	struct qce_alg_template *tmpl = to_ahash_tmpl(req->base.tfm);
 	struct qce_device *qce = tmpl->qce;
-	struct scatterlist *sg_last, *sg;
-	unsigned int total, len;
+	unsigned int total;
 	unsigned int hash_later;
-	unsigned int nbytes;
 	unsigned int blocksize;
 
 	blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
@@ -238,28 +236,8 @@ static int qce_ahash_update(struct ahash_request *req)
 	if (!hash_later)
 		hash_later = blocksize;
 
-	if (hash_later) {
-		unsigned int src_offset = req->nbytes - hash_later;
-		scatterwalk_map_and_copy(rctx->buf, req->src, src_offset,
-					 hash_later, 0);
-	}
-
-	/* here nbytes is multiple of blocksize */
-	nbytes = total - hash_later;
-
-	len = rctx->buflen;
-	sg = sg_last = req->src;
-
-	while (len < nbytes && sg) {
-		if (len + sg_dma_len(sg) > nbytes)
-			break;
-		len += sg_dma_len(sg);
-		sg_last = sg;
-		sg = sg_next(sg);
-	}
-
-	if (!sg_last)
-		return -EINVAL;
+	scatterwalk_map_and_copy(rctx->buf, req->src, req->nbytes - hash_later,
+				 hash_later, 0);
 
 	if (rctx->buflen) {
 		sg_init_table(rctx->sg, 2);
@@ -268,7 +246,8 @@ static int qce_ahash_update(struct ahash_request *req)
 		req->src = rctx->sg;
 	}
 
-	req->nbytes = nbytes;
+	/* hash only complete blocks */
+	req->nbytes = total - hash_later;
 	rctx->buflen = hash_later;
 
 	return qce->async_req_enqueue(tmpl->qce, &req->base);
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thorsten Blum

Commit df12ef60c87b ("crypto: qce/sha - Do not modify scatterlist passed along with request") removed the only use of sg_last, rendering the scatterlist traversal useless. Remove it and its local variables.

Also remove the redundant hash_later check, inline the source offset, and assign the number of complete blocks directly to req->nbytes.

---

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 11 lines · Thorsten Blum

Commit df12ef60c87b ("crypto: qce/sha - Do not modify scatterlist passed along with request") removed the only use of sg_last, rendering the scatterlist traversal useless. Remove it and its local variables.

Also remove the redundant hash_later check, inline the source offset, and assign the number of complete blocks directly to req->nbytes.

---
 drivers/crypto/qce/sha.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt