* [PATCH] crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev
@ 2026-04-27 21:35 Thorsten Blum
2026-05-05 9:29 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-04-27 21:35 UTC (permalink / raw)
To: Jia Jie Ho, William Qiu, Herbert Xu, David S. Miller
Cc: Thorsten Blum, linux-crypto, linux-kernel
Use list_first_entry_or_null() to simplify starfive_cryp_find_dev() and
remove the now-unused local variable 'struct starfive_cryp_dev *tmp'.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/starfive/jh7110-cryp.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/crypto/starfive/jh7110-cryp.c b/drivers/crypto/starfive/jh7110-cryp.c
index 42114e9364f0..e19cd7945968 100644
--- a/drivers/crypto/starfive/jh7110-cryp.c
+++ b/drivers/crypto/starfive/jh7110-cryp.c
@@ -36,19 +36,14 @@ static struct starfive_dev_list dev_list = {
struct starfive_cryp_dev *starfive_cryp_find_dev(struct starfive_cryp_ctx *ctx)
{
- struct starfive_cryp_dev *cryp = NULL, *tmp;
+ struct starfive_cryp_dev *cryp;
spin_lock_bh(&dev_list.lock);
- if (!ctx->cryp) {
- list_for_each_entry(tmp, &dev_list.dev_list, list) {
- cryp = tmp;
- break;
- }
- ctx->cryp = cryp;
- } else {
- cryp = ctx->cryp;
- }
-
+ if (!ctx->cryp)
+ ctx->cryp = list_first_entry_or_null(&dev_list.dev_list,
+ struct starfive_cryp_dev,
+ list);
+ cryp = ctx->cryp;
spin_unlock_bh(&dev_list.lock);
return cryp;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev
2026-04-27 21:35 [PATCH] crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev Thorsten Blum
@ 2026-05-05 9:29 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-05-05 9:29 UTC (permalink / raw)
To: Thorsten Blum
Cc: Jia Jie Ho, William Qiu, David S. Miller, linux-crypto,
linux-kernel
On Mon, Apr 27, 2026 at 11:35:06PM +0200, Thorsten Blum wrote:
> Use list_first_entry_or_null() to simplify starfive_cryp_find_dev() and
> remove the now-unused local variable 'struct starfive_cryp_dev *tmp'.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/starfive/jh7110-cryp.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-05 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 21:35 [PATCH] crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev Thorsten Blum
2026-05-05 9:29 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox