]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: qce - shrink code with devres clk helpers
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 3 Dec 2024 09:19:32 +0000 (10:19 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 14 Dec 2024 09:21:43 +0000 (17:21 +0800)
Use devm_clk_get_optional_enabled() to avoid having to enable the clocks
separately as well as putting the clocks in error path and the remove()
callback.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qce/core.c

index f9ff1dfc1defefd830295779afa8090d33738876..cdcddf8f9f02b367b24246be96e3adec902f65f9 100644 (file)
@@ -212,15 +212,15 @@ static int qce_crypto_probe(struct platform_device *pdev)
        if (ret < 0)
                return ret;
 
-       qce->core = devm_clk_get_optional(qce->dev, "core");
+       qce->core = devm_clk_get_optional_enabled(qce->dev, "core");
        if (IS_ERR(qce->core))
                return PTR_ERR(qce->core);
 
-       qce->iface = devm_clk_get_optional(qce->dev, "iface");
+       qce->iface = devm_clk_get_optional_enabled(qce->dev, "iface");
        if (IS_ERR(qce->iface))
                return PTR_ERR(qce->iface);
 
-       qce->bus = devm_clk_get_optional(qce->dev, "bus");
+       qce->bus = devm_clk_get_optional_enabled(qce->dev, "bus");
        if (IS_ERR(qce->bus))
                return PTR_ERR(qce->bus);
 
@@ -232,21 +232,9 @@ static int qce_crypto_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       ret = clk_prepare_enable(qce->core);
-       if (ret)
-               return ret;
-
-       ret = clk_prepare_enable(qce->iface);
-       if (ret)
-               goto err_clks_core;
-
-       ret = clk_prepare_enable(qce->bus);
-       if (ret)
-               goto err_clks_iface;
-
        ret = qce_dma_request(qce->dev, &qce->dma);
        if (ret)
-               goto err_clks;
+               return ret;
 
        ret = qce_check_version(qce);
        if (ret)
@@ -268,12 +256,6 @@ static int qce_crypto_probe(struct platform_device *pdev)
 
 err_dma:
        qce_dma_release(&qce->dma);
-err_clks:
-       clk_disable_unprepare(qce->bus);
-err_clks_iface:
-       clk_disable_unprepare(qce->iface);
-err_clks_core:
-       clk_disable_unprepare(qce->core);
 
        return ret;
 }
@@ -285,9 +267,6 @@ static void qce_crypto_remove(struct platform_device *pdev)
        tasklet_kill(&qce->done_tasklet);
        qce_unregister_algs(qce);
        qce_dma_release(&qce->dma);
-       clk_disable_unprepare(qce->bus);
-       clk_disable_unprepare(qce->iface);
-       clk_disable_unprepare(qce->core);
 }
 
 static const struct of_device_id qce_crypto_of_match[] = {