crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev
Subsystems (2)
PATCH 1/2 crypto: stm32 - use list_first_entry_or_null to simplify hash_find_dev
Use list_first_entry_or_null() to simplify stm32_hash_find_dev() and remove the now-unused local variable 'struct stm32_hash_dev *tmp'.
--- drivers/crypto/stm32/stm32-hash.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/crypto/stm32/stm32-hash.c +5 -11
@@ -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;
PATCH 2/2 crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
Use list_first_entry_or_null() to simplify stm32_cryp_find_dev() and remove the now-unused local variable 'struct stm32_cryp *tmp'.
--- drivers/crypto/stm32/stm32-cryp.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/crypto/stm32/stm32-cryp.c +5 -11
@@ -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;
Re: [PATCH 2/2] crypto: stm32 - use list_first_entry_or_null to simplify cryp_find_dev
Quoted 4 lines · Thorsten Blum
Use
list_first_entry_or_null()to simplifystm32_cryp_find_dev()and remove the now-unused local variable 'structstm32_cryp*tmp'.Signed-off-by Thorsten Blum <[email protected]>
Signature · 1 line
Kees Cook
Herbert Xu
maintainerQuoted 7 lines · Thorsten Blum
Use
list_first_entry_or_null()to simplifystm32_hash_find_dev()and remove the now-unused local variable 'structstm32_hash_dev*tmp'.Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/stm32/stm32-hash.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
All 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