mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH'
@ 2021-03-19 10:44 Hui Tang
  2021-03-19 10:44 ` [PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH' Hui Tang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hui Tang @ 2021-03-19 10:44 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, linux-kernel

Remove 'CONFIG_CRYPTO_DH' and optimise 'hpre_algs_register' error path.

Hui Tang (2):
  crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH'
  crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path

 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 30 ++++++++++-------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

--
2.8.1


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

* [PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH'
  2021-03-19 10:44 [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Hui Tang
@ 2021-03-19 10:44 ` Hui Tang
  2021-03-19 10:44 ` [PATCH 2/2] crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path Hui Tang
  2021-03-26  9:32 ` [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Hui Tang @ 2021-03-19 10:44 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, linux-kernel

'CRYPTO_DH' has selected in 'Kconfig', so delete 'CONFIG_CRYPTO_DH'.

Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 53068d2..50ccd10 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -546,7 +546,6 @@ static int hpre_send(struct hpre_ctx *ctx, struct hpre_sqe *msg)
 	return ret;
 }
 
-#ifdef CONFIG_CRYPTO_DH
 static int hpre_dh_compute_value(struct kpp_request *req)
 {
 	struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
@@ -719,7 +718,6 @@ static void hpre_dh_exit_tfm(struct crypto_kpp *tfm)
 
 	hpre_dh_clear_ctx(ctx, true);
 }
-#endif
 
 static void hpre_rsa_drop_leading_zeros(const char **ptr, size_t *len)
 {
@@ -1893,7 +1891,6 @@ static struct akcipher_alg rsa = {
 	},
 };
 
-#ifdef CONFIG_CRYPTO_DH
 static struct kpp_alg dh = {
 	.set_secret = hpre_dh_set_secret,
 	.generate_public_key = hpre_dh_compute_value,
@@ -1910,7 +1907,6 @@ static struct kpp_alg dh = {
 		.cra_module = THIS_MODULE,
 	},
 };
-#endif
 
 static struct kpp_alg ecdh_nist_p192 = {
 	.set_secret = hpre_ecdh_set_secret,
@@ -1995,13 +1991,12 @@ int hpre_algs_register(struct hisi_qm *qm)
 	ret = crypto_register_akcipher(&rsa);
 	if (ret)
 		return ret;
-#ifdef CONFIG_CRYPTO_DH
+
 	ret = crypto_register_kpp(&dh);
 	if (ret) {
 		crypto_unregister_akcipher(&rsa);
 		return ret;
 	}
-#endif
 
 	if (qm->ver >= QM_HW_V3) {
 		ret = hpre_register_ecdh();
@@ -2016,9 +2011,7 @@ int hpre_algs_register(struct hisi_qm *qm)
 	return 0;
 
 reg_err:
-#ifdef CONFIG_CRYPTO_DH
 	crypto_unregister_kpp(&dh);
-#endif
 	crypto_unregister_akcipher(&rsa);
 	return ret;
 }
@@ -2030,8 +2023,6 @@ void hpre_algs_unregister(struct hisi_qm *qm)
 		hpre_unregister_ecdh();
 	}
 
-#ifdef CONFIG_CRYPTO_DH
 	crypto_unregister_kpp(&dh);
-#endif
 	crypto_unregister_akcipher(&rsa);
 }
-- 
2.8.1


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

* [PATCH 2/2] crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path
  2021-03-19 10:44 [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Hui Tang
  2021-03-19 10:44 ` [PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH' Hui Tang
@ 2021-03-19 10:44 ` Hui Tang
  2021-03-26  9:32 ` [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Hui Tang @ 2021-03-19 10:44 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, xuzaibo, wangzhou1, linux-kernel

There is redundant code especially when registing new algorithms
in the future.

Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 50ccd10..b77473b 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -1993,25 +1993,24 @@ int hpre_algs_register(struct hisi_qm *qm)
 		return ret;
 
 	ret = crypto_register_kpp(&dh);
-	if (ret) {
-		crypto_unregister_akcipher(&rsa);
-		return ret;
-	}
+	if (ret)
+		goto unreg_rsa;
 
 	if (qm->ver >= QM_HW_V3) {
 		ret = hpre_register_ecdh();
 		if (ret)
-			goto reg_err;
+			goto unreg_dh;
 		ret = crypto_register_kpp(&curve25519_alg);
-		if (ret) {
-			hpre_unregister_ecdh();
-			goto reg_err;
-		}
+		if (ret)
+			goto unreg_ecdh;
 	}
 	return 0;
 
-reg_err:
+unreg_ecdh:
+	hpre_unregister_ecdh();
+unreg_dh:
 	crypto_unregister_kpp(&dh);
+unreg_rsa:
 	crypto_unregister_akcipher(&rsa);
 	return ret;
 }
-- 
2.8.1


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

* Re: [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH'
  2021-03-19 10:44 [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Hui Tang
  2021-03-19 10:44 ` [PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH' Hui Tang
  2021-03-19 10:44 ` [PATCH 2/2] crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path Hui Tang
@ 2021-03-26  9:32 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2021-03-26  9:32 UTC (permalink / raw)
  To: Hui Tang; +Cc: davem, linux-crypto, xuzaibo, wangzhou1, linux-kernel

On Fri, Mar 19, 2021 at 06:44:17PM +0800, Hui Tang wrote:
> Remove 'CONFIG_CRYPTO_DH' and optimise 'hpre_algs_register' error path.
> 
> Hui Tang (2):
>   crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH'
>   crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path
> 
>  drivers/crypto/hisilicon/hpre/hpre_crypto.c | 30 ++++++++++-------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2021-03-26  9:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 10:44 [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Hui Tang
2021-03-19 10:44 ` [PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH' Hui Tang
2021-03-19 10:44 ` [PATCH 2/2] crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path Hui Tang
2021-03-26  9:32 ` [PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH' Herbert Xu

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

all inboxes | Powered by JetHome®