From: Thorsten Blum <thorsten.blum@linux.dev>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Colin Ian King" <colin.i.king@gmail.com>,
"Kees Cook" <kees@kernel.org>,
"Maxime Méré" <maxime.mere@foss.st.com>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Thorsten Blum" <thorsten.blum@linux.dev>
Cc: linux-crypto@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
Date: Fri, 20 Mar 2026 09:49:14 +0100 [thread overview]
Message-ID: <20260320084914.7180-4-thorsten.blum@linux.dev> (raw)
In-Reply-To: <20260320084914.7180-3-thorsten.blum@linux.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>
---
drivers/crypto/stm32/stm32-cryp.c | 16 +++++-----------
1 file 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;
next prev parent reply other threads:[~2026-03-20 8:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 8:49 [PATCH 1/2] crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev Thorsten Blum
2026-03-20 8:49 ` Thorsten Blum [this message]
2026-03-20 18:26 ` [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev Kees Cook
2026-03-27 10:08 ` [PATCH 1/2] crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260320084914.7180-4-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=alexandre.torgue@foss.st.com \
--cc=colin.i.king@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kees@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.mere@foss.st.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.