From: Yejune Deng <yejune.deng@gmail.com>
To: xuzaibo@huawei.com, herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
yejune.deng@gmail.com
Subject: [PATCH] crypto: hisilicon/trng replace atomic_add_return()
Date: Tue, 1 Dec 2020 14:50:18 +0800 [thread overview]
Message-ID: <1606805418-4739-1-git-send-email-yejune.deng@gmail.com> (raw)
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
next reply other threads:[~2020-12-01 6:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 6:50 Yejune Deng [this message]
2020-12-11 10:13 ` [PATCH] crypto: hisilicon/trng replace atomic_add_return() Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1606805418-4739-1-git-send-email-yejune.deng@gmail.com \
--to=yejune.deng@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xuzaibo@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).