2022-08-07 21:22:56

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] soc/tegra: pmc: Use devm_clk_get_optional()

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 <[email protected]>
---
drivers/soc/tegra/pmc.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 6a4b8f7e7948..016762f88fff 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -2885,17 +2885,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
--
2.34.1


2022-09-15 12:09:28

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH] soc/tegra: pmc: Use devm_clk_get_optional()

On Sun, Aug 07, 2022 at 10:55:59PM +0200, Christophe JAILLET wrote:
> 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 <[email protected]>
> ---
> drivers/soc/tegra/pmc.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)

Applied, thanks.

Thierry


Attachments:
(No filename) (476.00 B)
signature.asc (849.00 B)
Download all attachments