Skip to content

Commit 323abf2

Browse files
ebiggersherbertx
authored andcommitted
crypto: s5p-sss - use the new scatterwalk functions
s5p_sg_copy_buf() open-coded a copy from/to a scatterlist using scatterwalk_* functions that are planned for removal. Replace it with the new functions memcpy_from_sglist() and memcpy_to_sglist() instead. Also take the opportunity to replace calls to scatterwalk_map_and_copy() in the same file; this eliminates the confusing 'out' argument. Cc: Krzysztof Kozlowski <krzk@kernel.org> Cc: Vladimir Zapolskiy <vz@mleia.com> Cc: linux-samsung-soc@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent e7d5d8a commit 323abf2

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

drivers/crypto/s5p-sss.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -458,19 +458,6 @@ static void s5p_free_sg_cpy(struct s5p_aes_dev *dev, struct scatterlist **sg)
458458
*sg = NULL;
459459
}
460460

461-
static void s5p_sg_copy_buf(void *buf, struct scatterlist *sg,
462-
unsigned int nbytes, int out)
463-
{
464-
struct scatter_walk walk;
465-
466-
if (!nbytes)
467-
return;
468-
469-
scatterwalk_start(&walk, sg);
470-
scatterwalk_copychunks(buf, &walk, nbytes, out);
471-
scatterwalk_done(&walk, out, 0);
472-
}
473-
474461
static void s5p_sg_done(struct s5p_aes_dev *dev)
475462
{
476463
struct skcipher_request *req = dev->req;
@@ -480,8 +467,8 @@ static void s5p_sg_done(struct s5p_aes_dev *dev)
480467
dev_dbg(dev->dev,
481468
"Copying %d bytes of output data back to original place\n",
482469
dev->req->cryptlen);
483-
s5p_sg_copy_buf(sg_virt(dev->sg_dst_cpy), dev->req->dst,
484-
dev->req->cryptlen, 1);
470+
memcpy_to_sglist(dev->req->dst, 0, sg_virt(dev->sg_dst_cpy),
471+
dev->req->cryptlen);
485472
}
486473
s5p_free_sg_cpy(dev, &dev->sg_src_cpy);
487474
s5p_free_sg_cpy(dev, &dev->sg_dst_cpy);
@@ -526,7 +513,7 @@ static int s5p_make_sg_cpy(struct s5p_aes_dev *dev, struct scatterlist *src,
526513
return -ENOMEM;
527514
}
528515

529-
s5p_sg_copy_buf(pages, src, dev->req->cryptlen, 0);
516+
memcpy_from_sglist(pages, src, 0, dev->req->cryptlen);
530517

531518
sg_init_table(*dst, 1);
532519
sg_set_buf(*dst, pages, len);
@@ -1035,8 +1022,7 @@ static int s5p_hash_copy_sgs(struct s5p_hash_reqctx *ctx,
10351022
if (ctx->bufcnt)
10361023
memcpy(buf, ctx->dd->xmit_buf, ctx->bufcnt);
10371024

1038-
scatterwalk_map_and_copy(buf + ctx->bufcnt, sg, ctx->skip,
1039-
new_len, 0);
1025+
memcpy_from_sglist(buf + ctx->bufcnt, sg, ctx->skip, new_len);
10401026
sg_init_table(ctx->sgl, 1);
10411027
sg_set_buf(ctx->sgl, buf, len);
10421028
ctx->sg = ctx->sgl;
@@ -1229,8 +1215,7 @@ static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
12291215
if (len > nbytes)
12301216
len = nbytes;
12311217

1232-
scatterwalk_map_and_copy(ctx->buffer + ctx->bufcnt, req->src,
1233-
0, len, 0);
1218+
memcpy_from_sglist(ctx->buffer + ctx->bufcnt, req->src, 0, len);
12341219
ctx->bufcnt += len;
12351220
nbytes -= len;
12361221
ctx->skip = len;
@@ -1253,9 +1238,8 @@ static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
12531238
hash_later = ctx->total - xmit_len;
12541239
/* copy hash_later bytes from end of req->src */
12551240
/* previous bytes are in xmit_buf, so no overwrite */
1256-
scatterwalk_map_and_copy(ctx->buffer, req->src,
1257-
req->nbytes - hash_later,
1258-
hash_later, 0);
1241+
memcpy_from_sglist(ctx->buffer, req->src,
1242+
req->nbytes - hash_later, hash_later);
12591243
}
12601244

12611245
if (xmit_len > BUFLEN) {
@@ -1267,8 +1251,8 @@ static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
12671251
/* have buffered data only */
12681252
if (unlikely(!ctx->bufcnt)) {
12691253
/* first update didn't fill up buffer */
1270-
scatterwalk_map_and_copy(ctx->dd->xmit_buf, req->src,
1271-
0, xmit_len, 0);
1254+
memcpy_from_sglist(ctx->dd->xmit_buf, req->src,
1255+
0, xmit_len);
12721256
}
12731257

12741258
sg_init_table(ctx->sgl, 1);
@@ -1506,8 +1490,8 @@ static int s5p_hash_update(struct ahash_request *req)
15061490
return 0;
15071491

15081492
if (ctx->bufcnt + req->nbytes <= BUFLEN) {
1509-
scatterwalk_map_and_copy(ctx->buffer + ctx->bufcnt, req->src,
1510-
0, req->nbytes, 0);
1493+
memcpy_from_sglist(ctx->buffer + ctx->bufcnt, req->src,
1494+
0, req->nbytes);
15111495
ctx->bufcnt += req->nbytes;
15121496
return 0;
15131497
}

0 commit comments

Comments
 (0)