diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-18 12:24:37 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-20 10:11:08 -0400 |
commit | 58953e15ef015ba9136b7234a7098cf827428999 (patch) | |
tree | 649a896c3b9c6e3e3520574aeaf769f68e5f55a0 | |
parent | e41bbebddec44f7c06585f42686b2a529513fc6a (diff) |
crypto: marvell/cesa - rearrange last request handling
Move the test for the last request out of mv_cesa_ahash_dma_last_req()
to its caller, and move the mv_cesa_dma_add_frag() down into this
function.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/marvell/hash.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index ce457d6e900e..71d29f025bbe 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
@@ -522,15 +522,21 @@ static struct mv_cesa_op_ctx * | |||
522 | mv_cesa_ahash_dma_last_req(struct mv_cesa_tdma_chain *chain, | 522 | mv_cesa_ahash_dma_last_req(struct mv_cesa_tdma_chain *chain, |
523 | struct mv_cesa_ahash_dma_iter *dma_iter, | 523 | struct mv_cesa_ahash_dma_iter *dma_iter, |
524 | struct mv_cesa_ahash_req *creq, | 524 | struct mv_cesa_ahash_req *creq, |
525 | struct mv_cesa_op_ctx *op, | 525 | unsigned int frag_len, gfp_t flags) |
526 | gfp_t flags) | ||
527 | { | 526 | { |
528 | struct mv_cesa_ahash_dma_req *ahashdreq = &creq->req.dma; | 527 | struct mv_cesa_ahash_dma_req *ahashdreq = &creq->req.dma; |
529 | unsigned int len, trailerlen, padoff = 0; | 528 | unsigned int len, trailerlen, padoff = 0; |
529 | struct mv_cesa_op_ctx *op; | ||
530 | int ret; | 530 | int ret; |
531 | 531 | ||
532 | if (!creq->last_req) | 532 | if (frag_len) { |
533 | return op; | 533 | op = mv_cesa_dma_add_frag(chain, &creq->op_tmpl, frag_len, |
534 | flags); | ||
535 | if (IS_ERR(op)) | ||
536 | return op; | ||
537 | } else { | ||
538 | op = NULL; | ||
539 | } | ||
534 | 540 | ||
535 | if (op && creq->len <= CESA_SA_DESC_MAC_SRC_TOTAL_LEN_MAX) { | 541 | if (op && creq->len <= CESA_SA_DESC_MAC_SRC_TOTAL_LEN_MAX) { |
536 | u32 frag = CESA_SA_DESC_CFG_NOT_FRAG; | 542 | u32 frag = CESA_SA_DESC_CFG_NOT_FRAG; |
@@ -657,16 +663,18 @@ static int mv_cesa_ahash_dma_req_init(struct ahash_request *req) | |||
657 | frag_len = iter.base.op_len; | 663 | frag_len = iter.base.op_len; |
658 | } | 664 | } |
659 | 665 | ||
660 | if (frag_len) { | 666 | /* |
667 | * At this point, frag_len indicates whether we have any data | ||
668 | * outstanding which needs an operation. Queue up the final | ||
669 | * operation, which depends whether this is the final request. | ||
670 | */ | ||
671 | if (creq->last_req) | ||
672 | op = mv_cesa_ahash_dma_last_req(&chain, &iter, creq, frag_len, | ||
673 | flags); | ||
674 | else if (frag_len) | ||
661 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, frag_len, | 675 | op = mv_cesa_dma_add_frag(&chain, &creq->op_tmpl, frag_len, |
662 | flags); | 676 | flags); |
663 | if (IS_ERR(op)) { | ||
664 | ret = PTR_ERR(op); | ||
665 | goto err_free_tdma; | ||
666 | } | ||
667 | } | ||
668 | 677 | ||
669 | op = mv_cesa_ahash_dma_last_req(&chain, &iter, creq, op, flags); | ||
670 | if (IS_ERR(op)) { | 678 | if (IS_ERR(op)) { |
671 | ret = PTR_ERR(op); | 679 | ret = PTR_ERR(op); |
672 | goto err_free_tdma; | 680 | goto err_free_tdma; |