linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: hisilicon/trng replace atomic_add_return()
@ 2020-12-01  6:50 Yejune Deng
  2020-12-11 10:13 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Yejune Deng @ 2020-12-01  6:50 UTC (permalink / raw)
  To: xuzaibo, herbert, davem; +Cc: linux-crypto, linux-kernel, yejune.deng

a set of atomic_inc_return() looks more neater

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 drivers/crypto/hisilicon/trng/trng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/trng/trng.c b/drivers/crypto/hisilicon/trng/trng.c
index a5033cf..2971268 100644
--- a/drivers/crypto/hisilicon/trng/trng.c
+++ b/drivers/crypto/hisilicon/trng/trng.c
@@ -267,12 +267,12 @@ static int hisi_trng_probe(struct platform_device *pdev)
 	}
 
 	hisi_trng_add_to_list(trng);
-	if (atomic_add_return(1, &trng_active_devs) == 1) {
+	if (atomic_inc_return(&trng_active_devs) == 1) {
 		ret = crypto_register_rng(&hisi_trng_alg);
 		if (ret) {
 			dev_err(&pdev->dev,
 				"failed to register crypto(%d)\n", ret);
-			atomic_sub_return(1, &trng_active_devs);
+			atomic_dec_return(&trng_active_devs);
 			goto err_remove_from_list;
 		}
 	}
@@ -289,7 +289,7 @@ static int hisi_trng_probe(struct platform_device *pdev)
 	return ret;
 
 err_crypto_unregister:
-	if (atomic_sub_return(1, &trng_active_devs) == 0)
+	if (atomic_dec_return(&trng_active_devs) == 0)
 		crypto_unregister_rng(&hisi_trng_alg);
 
 err_remove_from_list:
@@ -305,7 +305,7 @@ static int hisi_trng_remove(struct platform_device *pdev)
 	while (hisi_trng_del_from_list(trng))
 		;
 
-	if (atomic_sub_return(1, &trng_active_devs) == 0)
+	if (atomic_dec_return(&trng_active_devs) == 0)
 		crypto_unregister_rng(&hisi_trng_alg);
 
 	return 0;
-- 
1.9.1


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

* Re: [PATCH] crypto: hisilicon/trng replace atomic_add_return()
  2020-12-01  6:50 [PATCH] crypto: hisilicon/trng replace atomic_add_return() Yejune Deng
@ 2020-12-11 10:13 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2020-12-11 10:13 UTC (permalink / raw)
  To: Yejune Deng; +Cc: xuzaibo, davem, linux-crypto, linux-kernel

On Tue, Dec 01, 2020 at 02:50:18PM +0800, Yejune Deng wrote:
> a set of atomic_inc_return() looks more neater
> 
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
>  drivers/crypto/hisilicon/trng/trng.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 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] 2+ messages in thread

end of thread, other threads:[~2020-12-11 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-01  6:50 [PATCH] crypto: hisilicon/trng replace atomic_add_return() Yejune Deng
2020-12-11 10:13 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).