]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 27 Apr 2026 21:35:06 +0000 (23:35 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 7 May 2026 08:10:02 +0000 (16:10 +0800)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/starfive/jh7110-cryp.c

index 42114e9364f0d02481076c382ee95107d86feebd..e19cd79459687c0877726da867af66a7c0b142bd 100644 (file)
@@ -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;