Skip to contentSkip to conversation

crypto: img-hash - Use unregister_ahashes in img_{un}register_algs

PATCH In review Thorsten Blum 2 participants 2 messages Feb 1 – Feb 6 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: img-hash - Use unregister_ahashes in img_{un}register_algs

Replace the for loops with calls to crypto_unregister_ahashes(). In img_register_algs(), return 'err' immediately and remove the goto statement to simplify the error handling code.

Convert img_unregister_algs() to a void function since its return value is never used.

---
 drivers/crypto/img-hash.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/crypto/img-hash.c +7 -14
index f22c12e36b56..7195c37dd102 100644
@@ -870,25 +870,18 @@ static int img_register_algs(struct img_hash_dev *hdev)
 
 	for (i = 0; i < ARRAY_SIZE(img_algs); i++) {
 		err = crypto_register_ahash(&img_algs[i]);
-		if (err)
-			goto err_reg;
+		if (err) {
+			crypto_unregister_ahashes(img_algs, i);
+			return err;
+		}
 	}
-	return 0;
 
-err_reg:
-	for (; i--; )
-		crypto_unregister_ahash(&img_algs[i]);
-
-	return err;
+	return 0;
 }
 
-static int img_unregister_algs(struct img_hash_dev *hdev)
+static void img_unregister_algs(struct img_hash_dev *hdev)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(img_algs); i++)
-		crypto_unregister_ahash(&img_algs[i]);
-	return 0;
+	crypto_unregister_ahashes(img_algs, ARRAY_SIZE(img_algs));
 }
 
 static void img_hash_done_task(unsigned long data)
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer
#1 lore raw
Quoted 11 lines · Thorsten Blum

Replace the for loops with calls to crypto_unregister_ahashes(). In img_register_algs(), return 'err' immediately and remove the goto statement to simplify the error handling code.

Convert img_unregister_algs() to a void function since its return value is never used.

---
 drivers/crypto/img-hash.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 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