crypto: img-hash - use list_first_entry_or_null to simplify digest
PATCH 1/2 crypto: img-hash - use list_first_entry_or_null to simplify digest
Use list_first_entry_or_null() to simplify img_hash_digest() and remove the now-unused local 'struct img_hash_dev *' variables. Use 'ctx->hdev' when calling img_hash_handle_queue() instead of 'tctx->hdev'.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/crypto/img-hash.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/crypto/img-hash.c +6 -15
@@ -629,24 +629,15 @@ static int img_hash_digest(struct ahash_request *req)struct crypto_ahash *tfm =crypto_ahash_reqtfm (req);struct img_hash_ctx *tctx =crypto_ahash_ctx (tfm);struct img_hash_request_ctx *ctx =ahash_request_ctx (req); -struct img_hash_dev *hdev =NULL ; -struct img_hash_dev *tmp;int err;spin_lock (&img_hash.lock); -if (!tctx->hdev) { -list_for_each_entry (tmp, &img_hash.dev_list, list) { - hdev = tmp; -break ; - } - tctx->hdev = hdev; - - }else { - hdev = tctx->hdev; - } - +if (!tctx->hdev) + tctx->hdev =list_first_entry_or_null (&img_hash.dev_list, + struct img_hash_dev, list); + ctx->hdev = tctx->hdev;spin_unlock (&img_hash.lock); - ctx->hdev = hdev; + ctx->flags =0 ; ctx->digsize =crypto_ahash_digestsize (tfm);
@@ -675,7 +666,7 @@ static int img_hash_digest(struct ahash_request *req) ctx->sgfirst = req->src; ctx->nents =sg_nents (ctx->sg); - err =img_hash_handle_queue (tctx->hdev, req); + err =img_hash_handle_queue (ctx->hdev, req);return err; }
PATCH 2/2 crypto: img-hash - drop redundant return variable
In img_hash_digest(), remove the redundant return variable 'err' and return img_hash_handle_queue() directly.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/crypto/img-hash.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/img-hash.c +1 -4
@@ -629,7 +629,6 @@ static int img_hash_digest(struct ahash_request *req)struct crypto_ahash *tfm =crypto_ahash_reqtfm (req);struct img_hash_ctx *tctx =crypto_ahash_ctx (tfm);struct img_hash_request_ctx *ctx =ahash_request_ctx (req); -int err;spin_lock (&img_hash.lock);if (!tctx->hdev)
@@ -666,9 +665,7 @@ static int img_hash_digest(struct ahash_request *req) ctx->sgfirst = req->src; ctx->nents =sg_nents (ctx->sg); - err =img_hash_handle_queue (ctx->hdev, req); - -return err; +return img_hash_handle_queue (ctx->hdev, req); }static int img_hash_cra_init (struct crypto_tfm *tfm,const char *alg_name)
Herbert Xu
maintainerQuoted 8 lines · Thorsten Blum
Use
list_first_entry_or_null()to simplifyimg_hash_digest()and remove the now-unused local 'structimg_hash_dev*' variables. Use 'ctx->hdev' when callingimg_hash_handle_queue()instead of 'tctx->hdev'.Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/img-hash.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 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