]> Git Repo - linux.git/commitdiff
crypto: hisilicon/trng - replace atomic_add_return()
authorYejune Deng <[email protected]>
Tue, 1 Dec 2020 06:50:18 +0000 (14:50 +0800)
committerHerbert Xu <[email protected]>
Fri, 11 Dec 2020 10:12:05 +0000 (21:12 +1100)
a set of atomic_inc_return() looks more neater

Signed-off-by: Yejune Deng <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
drivers/crypto/hisilicon/trng/trng.c

index a5033cf09e2b0b4362a1b44b8f0fb9ec7f47d2a4..29712685498a78b35f7f1a5599ccbc17505d6eef 100644 (file)
@@ -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;
This page took 0.056867 seconds and 4 git commands to generate.