Skip to contentSkip to conversation

crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev

PATCH In review Thorsten Blum 2 participants 2 messages Apr 27 – May 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: starfive - use list_first_entry_or_null to simplify cryp_find_dev

Use list_first_entry_or_null() to simplify starfive_cryp_find_dev() and remove the now-unused local variable 'struct starfive_cryp_dev *tmp'.

---
 drivers/crypto/starfive/jh7110-cryp.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/crypto/starfive/jh7110-cryp.c +6 -11
index 42114e9364f0..e19cd7945968 100644
@@ -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;
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

Use list_first_entry_or_null() to simplify starfive_cryp_find_dev() and remove the now-unused local variable 'struct starfive_cryp_dev *tmp'.

---
 drivers/crypto/starfive/jh7110-cryp.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt