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
  0 siblings, 1 reply; 3+ 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] 3+ messages in thread

* [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
  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 ` Thorsten Blum
  2026-03-20 18:26   ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-03-20  8:49 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue,
	Colin Ian King, Kees Cook, Maxime Méré, Sakari Ailus,
	Thorsten Blum
  Cc: linux-crypto, linux-stm32, linux-arm-kernel, linux-kernel

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

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

diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c
index 3c9b3f679461..b79877099942 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -361,19 +361,13 @@ static int stm32_cryp_it_start(struct stm32_cryp *cryp);
 
 static struct stm32_cryp *stm32_cryp_find_dev(struct stm32_cryp_ctx *ctx)
 {
-	struct stm32_cryp *tmp, *cryp = NULL;
+	struct stm32_cryp *cryp;
 
 	spin_lock_bh(&cryp_list.lock);
-	if (!ctx->cryp) {
-		list_for_each_entry(tmp, &cryp_list.dev_list, list) {
-			cryp = tmp;
-			break;
-		}
-		ctx->cryp = cryp;
-	} else {
-		cryp = ctx->cryp;
-	}
-
+	if (!ctx->cryp)
+		ctx->cryp = list_first_entry_or_null(&cryp_list.dev_list,
+						     struct stm32_cryp, list);
+	cryp = ctx->cryp;
 	spin_unlock_bh(&cryp_list.lock);
 
 	return cryp;

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

* Re: [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
  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
  0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2026-03-20 18:26 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue,
	Colin Ian King, Maxime Méré, Sakari Ailus, linux-crypto,
	linux-stm32, linux-arm-kernel, linux-kernel

On Fri, Mar 20, 2026 at 09:49:14AM +0100, Thorsten Blum wrote:
> Use list_first_entry_or_null() to simplify stm32_cryp_find_dev() and
> remove the now-unused local variable 'struct stm32_cryp *tmp'.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

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

end of thread, other threads:[~2026-03-20 18:26 UTC | newest]

Thread overview: 3+ 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

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