Skip to content

Commit a320dc2

Browse files
YajunDengherbertx
authored andcommitted
crypto: hisilicon/trng - replace atomic_add_return()
a set of atomic_inc_return() looks more neater Signed-off-by: Yejune Deng <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 8857433 commit a320dc2

File tree

1 file changed

+4
-4
lines changed
  • drivers/crypto/hisilicon/trng

1 file changed

+4
-4
lines changed

drivers/crypto/hisilicon/trng/trng.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ static int hisi_trng_probe(struct platform_device *pdev)
267267
}
268268

269269
hisi_trng_add_to_list(trng);
270-
if (atomic_add_return(1, &trng_active_devs) == 1) {
270+
if (atomic_inc_return(&trng_active_devs) == 1) {
271271
ret = crypto_register_rng(&hisi_trng_alg);
272272
if (ret) {
273273
dev_err(&pdev->dev,
274274
"failed to register crypto(%d)\n", ret);
275-
atomic_sub_return(1, &trng_active_devs);
275+
atomic_dec_return(&trng_active_devs);
276276
goto err_remove_from_list;
277277
}
278278
}
@@ -289,7 +289,7 @@ static int hisi_trng_probe(struct platform_device *pdev)
289289
return ret;
290290

291291
err_crypto_unregister:
292-
if (atomic_sub_return(1, &trng_active_devs) == 0)
292+
if (atomic_dec_return(&trng_active_devs) == 0)
293293
crypto_unregister_rng(&hisi_trng_alg);
294294

295295
err_remove_from_list:
@@ -305,7 +305,7 @@ static int hisi_trng_remove(struct platform_device *pdev)
305305
while (hisi_trng_del_from_list(trng))
306306
;
307307

308-
if (atomic_sub_return(1, &trng_active_devs) == 0)
308+
if (atomic_dec_return(&trng_active_devs) == 0)
309309
crypto_unregister_rng(&hisi_trng_alg);
310310

311311
return 0;

0 commit comments

Comments
 (0)