soc/tegra: pmc: Use devm_clk_get_optional()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 7 Aug 2022 20:55:59 +0000 (22:55 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 15 Sep 2022 11:13:40 +0000 (13:13 +0200)
Use devm_clk_get_optional() instead of hand writing it.

While at it, use dev_err_probe() to further simplify the code. This is also
less verbose if clk_get() returns -EPROBE_DEFER.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/pmc.c

index 03d614a..961b2de 100644 (file)
@@ -2904,17 +2904,10 @@ static int tegra_pmc_probe(struct platform_device *pdev)
                pmc->scratch = base;
        }
 
-       pmc->clk = devm_clk_get(&pdev->dev, "pclk");
-       if (IS_ERR(pmc->clk)) {
-               err = PTR_ERR(pmc->clk);
-
-               if (err != -ENOENT) {
-                       dev_err(&pdev->dev, "failed to get pclk: %d\n", err);
-                       return err;
-               }
-
-               pmc->clk = NULL;
-       }
+       pmc->clk = devm_clk_get_optional(&pdev->dev, "pclk");
+       if (IS_ERR(pmc->clk))
+               return dev_err_probe(&pdev->dev, PTR_ERR(pmc->clk),
+                                    "failed to get pclk\n");
 
        /*
         * PMC should be last resort for restarting since it soft-resets