diff options
author | Gilad Ben-Yossef <gilad@benyossef.com> | 2019-04-18 09:38:52 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-04-25 03:38:14 -0400 |
commit | b7ec8530687a5b44654ee59c236579c2d890357f (patch) | |
tree | 25918630e1d821ca70cd47085fdbd9de9892fdd9 /drivers/crypto/ccree/cc_buffer_mgr.c | |
parent | dcb2cf1d2c760bcf6390b72a9a74a3e5482ab949 (diff) |
crypto: ccree - use std api when possible
Move to use the std api sg_nents_for_len() when we do not in fact
require the extra information about the number of bytes in the last
entry provided by the in-driver variant cc_get_sgl_nents().
This also resolves a Coverity warning cause by us not using
the output value.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccree/cc_buffer_mgr.c')
-rw-r--r-- | drivers/crypto/ccree/cc_buffer_mgr.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 7c92373df351..ccb0257bdc58 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c | |||
@@ -133,9 +133,9 @@ void cc_zero_sgl(struct scatterlist *sgl, u32 data_len) | |||
133 | void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, | 133 | void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, |
134 | u32 to_skip, u32 end, enum cc_sg_cpy_direct direct) | 134 | u32 to_skip, u32 end, enum cc_sg_cpy_direct direct) |
135 | { | 135 | { |
136 | u32 nents, lbytes; | 136 | u32 nents; |
137 | 137 | ||
138 | nents = cc_get_sgl_nents(dev, sg, end, &lbytes); | 138 | nents = sg_nents_for_len(sg, end); |
139 | sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, | 139 | sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, |
140 | (direct == CC_SG_TO_BUF)); | 140 | (direct == CC_SG_TO_BUF)); |
141 | } | 141 | } |
@@ -519,7 +519,6 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) | |||
519 | unsigned int hw_iv_size = areq_ctx->hw_iv_size; | 519 | unsigned int hw_iv_size = areq_ctx->hw_iv_size; |
520 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); | 520 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
521 | struct cc_drvdata *drvdata = dev_get_drvdata(dev); | 521 | struct cc_drvdata *drvdata = dev_get_drvdata(dev); |
522 | u32 dummy; | ||
523 | u32 size_to_unmap = 0; | 522 | u32 size_to_unmap = 0; |
524 | 523 | ||
525 | if (areq_ctx->mac_buf_dma_addr) { | 524 | if (areq_ctx->mac_buf_dma_addr) { |
@@ -583,15 +582,13 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) | |||
583 | if (areq_ctx->is_gcm4543) | 582 | if (areq_ctx->is_gcm4543) |
584 | size_to_unmap += crypto_aead_ivsize(tfm); | 583 | size_to_unmap += crypto_aead_ivsize(tfm); |
585 | 584 | ||
586 | dma_unmap_sg(dev, req->src, | 585 | dma_unmap_sg(dev, req->src, sg_nents_for_len(req->src, size_to_unmap), |
587 | cc_get_sgl_nents(dev, req->src, size_to_unmap, &dummy), | ||
588 | DMA_BIDIRECTIONAL); | 586 | DMA_BIDIRECTIONAL); |
589 | if (req->src != req->dst) { | 587 | if (req->src != req->dst) { |
590 | dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", | 588 | dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", |
591 | sg_virt(req->dst)); | 589 | sg_virt(req->dst)); |
592 | dma_unmap_sg(dev, req->dst, | 590 | dma_unmap_sg(dev, req->dst, |
593 | cc_get_sgl_nents(dev, req->dst, size_to_unmap, | 591 | sg_nents_for_len(req->dst, size_to_unmap), |
594 | &dummy), | ||
595 | DMA_BIDIRECTIONAL); | 592 | DMA_BIDIRECTIONAL); |
596 | } | 593 | } |
597 | if (drvdata->coherent && | 594 | if (drvdata->coherent && |
@@ -1429,8 +1426,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, | |||
1429 | if (total_in_len < block_size) { | 1426 | if (total_in_len < block_size) { |
1430 | dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", | 1427 | dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", |
1431 | curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); | 1428 | curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); |
1432 | areq_ctx->in_nents = | 1429 | areq_ctx->in_nents = sg_nents_for_len(src, nbytes); |
1433 | cc_get_sgl_nents(dev, src, nbytes, &dummy); | ||
1434 | sg_copy_to_buffer(src, areq_ctx->in_nents, | 1430 | sg_copy_to_buffer(src, areq_ctx->in_nents, |
1435 | &curr_buff[*curr_buff_cnt], nbytes); | 1431 | &curr_buff[*curr_buff_cnt], nbytes); |
1436 | *curr_buff_cnt += nbytes; | 1432 | *curr_buff_cnt += nbytes; |