summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2026-03-20 11:49:14 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2026-03-27 12:52:43 +0300
commit92c0a9bbcde6a748a40182fe32e3a1b2f9f1a23d (patch)
treeda43ae827a30c6d299a6ab9db885f30e4ea9f8b1
parent1a9670df56eac0a374cc2a5e9a63775de4c61837 (diff)
downloadlinux-92c0a9bbcde6a748a40182fe32e3a1b2f9f1a23d.tar.xz
crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
Use list_first_entry_or_null() to simplify stm32_cryp_find_dev() and remove the now-unused local variable 'struct stm32_cryp *tmp'. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Kees Cook <kees@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/stm32/stm32-cryp.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c
index 3c9b3f679461..b79877099942 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -361,19 +361,13 @@ static int stm32_cryp_it_start(struct stm32_cryp *cryp);
static struct stm32_cryp *stm32_cryp_find_dev(struct stm32_cryp_ctx *ctx)
{
- struct stm32_cryp *tmp, *cryp = NULL;
+ struct stm32_cryp *cryp;
spin_lock_bh(&cryp_list.lock);
- if (!ctx->cryp) {
- list_for_each_entry(tmp, &cryp_list.dev_list, list) {
- cryp = tmp;
- break;
- }
- ctx->cryp = cryp;
- } else {
- cryp = ctx->cryp;
- }
-
+ if (!ctx->cryp)
+ ctx->cryp = list_first_entry_or_null(&cryp_list.dev_list,
+ struct stm32_cryp, list);
+ cryp = ctx->cryp;
spin_unlock_bh(&cryp_list.lock);
return cryp;