public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev
@ 2026-03-20  8:49 Thorsten Blum
  2026-03-20  8:49 ` [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev Thorsten Blum
  2026-03-27 10:08 ` [PATCH 1/2] crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-03-20  8:49 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue,
	Sakari Ailus, Thorsten Blum
  Cc: linux-crypto, linux-stm32, linux-arm-kernel, linux-kernel

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/crypto/stm32/stm32-hash.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index d60147a7594e..dada5951082c 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -792,19 +792,13 @@ static int stm32_hash_dma_send(struct stm32_hash_dev *hdev)
 
 static struct stm32_hash_dev *stm32_hash_find_dev(struct stm32_hash_ctx *ctx)
 {
-	struct stm32_hash_dev *hdev = NULL, *tmp;
+	struct stm32_hash_dev *hdev;
 
 	spin_lock_bh(&stm32_hash.lock);
-	if (!ctx->hdev) {
-		list_for_each_entry(tmp, &stm32_hash.dev_list, list) {
-			hdev = tmp;
-			break;
-		}
-		ctx->hdev = hdev;
-	} else {
-		hdev = ctx->hdev;
-	}
-
+	if (!ctx->hdev)
+		ctx->hdev = list_first_entry_or_null(&stm32_hash.dev_list,
+						     struct stm32_hash_dev, list);
+	hdev = ctx->hdev;
 	spin_unlock_bh(&stm32_hash.lock);
 
 	return hdev;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-27 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev Thorsten Blum
2026-03-20 18:26   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox