Commit a320dc2f authored by Yejune Deng's avatar Yejune Deng Committed by Herbert Xu

crypto: hisilicon/trng - replace atomic_add_return()

a set of atomic_inc_return() looks more neater
Signed-off-by: default avatarYejune Deng <yejune.deng@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 88574332
...@@ -267,12 +267,12 @@ static int hisi_trng_probe(struct platform_device *pdev) ...@@ -267,12 +267,12 @@ static int hisi_trng_probe(struct platform_device *pdev)
} }
hisi_trng_add_to_list(trng); 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); ret = crypto_register_rng(&hisi_trng_alg);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to register crypto(%d)\n", ret); "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; goto err_remove_from_list;
} }
} }
...@@ -289,7 +289,7 @@ static int hisi_trng_probe(struct platform_device *pdev) ...@@ -289,7 +289,7 @@ static int hisi_trng_probe(struct platform_device *pdev)
return ret; return ret;
err_crypto_unregister: 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); crypto_unregister_rng(&hisi_trng_alg);
err_remove_from_list: err_remove_from_list:
...@@ -305,7 +305,7 @@ static int hisi_trng_remove(struct platform_device *pdev) ...@@ -305,7 +305,7 @@ static int hisi_trng_remove(struct platform_device *pdev)
while (hisi_trng_del_from_list(trng)) 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); crypto_unregister_rng(&hisi_trng_alg);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment