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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: img-hash - use list_first_entry_or_null to simplify digest

Use list_first_entry_or_null() to simplify img_hash_digest() and remove
the now-unused local 'struct img_hash_dev *' variables. Use 'ctx->hdev'
when calling img_hash_handle_queue() instead of 'tctx->hdev'.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
3a31b7fd cdadc143

+6 -15
+6 -15
drivers/crypto/img-hash.c
··· 629 629 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); 630 630 struct img_hash_ctx *tctx = crypto_ahash_ctx(tfm); 631 631 struct img_hash_request_ctx *ctx = ahash_request_ctx(req); 632 - struct img_hash_dev *hdev = NULL; 633 - struct img_hash_dev *tmp; 634 632 int err; 635 633 636 634 spin_lock(&img_hash.lock); 637 - if (!tctx->hdev) { 638 - list_for_each_entry(tmp, &img_hash.dev_list, list) { 639 - hdev = tmp; 640 - break; 641 - } 642 - tctx->hdev = hdev; 643 - 644 - } else { 645 - hdev = tctx->hdev; 646 - } 647 - 635 + if (!tctx->hdev) 636 + tctx->hdev = list_first_entry_or_null(&img_hash.dev_list, 637 + struct img_hash_dev, list); 638 + ctx->hdev = tctx->hdev; 648 639 spin_unlock(&img_hash.lock); 649 - ctx->hdev = hdev; 640 + 650 641 ctx->flags = 0; 651 642 ctx->digsize = crypto_ahash_digestsize(tfm); 652 643 ··· 666 675 ctx->sgfirst = req->src; 667 676 ctx->nents = sg_nents(ctx->sg); 668 677 669 - err = img_hash_handle_queue(tctx->hdev, req); 678 + err = img_hash_handle_queue(ctx->hdev, req); 670 679 671 680 return err; 672 681 }