Skip to contentSkip to conversation

crypto: atmel - use list_first_entry_or_null to simplify find_dev

PATCH In review Thorsten Blum 2 participants 2 messages Mar 8 – Mar 14

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

PATCH 1/1 crypto: atmel - use list_first_entry_or_null to simplify find_dev

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

---
 drivers/crypto/atmel-sha.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/crypto/atmel-sha.c +5 -12
index 1f1341a16c42..002b62902553 100644
@@ -404,20 +404,13 @@ static void atmel_sha_fill_padding(struct atmel_sha_reqctx *ctx, int length)
 
 static struct atmel_sha_dev *atmel_sha_find_dev(struct atmel_sha_ctx *tctx)
 {
-	struct atmel_sha_dev *dd = NULL;
-	struct atmel_sha_dev *tmp;
+	struct atmel_sha_dev *dd;
 
 	spin_lock_bh(&atmel_sha.lock);
-	if (!tctx->dd) {
-		list_for_each_entry(tmp, &atmel_sha.dev_list, list) {
-			dd = tmp;
-			break;
-		}
-		tctx->dd = dd;
-	} else {
-		dd = tctx->dd;
-	}
-
+	if (!tctx->dd)
+		tctx->dd = list_first_entry_or_null(&atmel_sha.dev_list,
+						    struct atmel_sha_dev, list);
+	dd = tctx->dd;
 	spin_unlock_bh(&atmel_sha.lock);
 
 	return dd;
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

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

---
 drivers/crypto/atmel-sha.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 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