mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
hwrng: exynos - Use devm_clk_get_enabled() to get the clock
Use devm_clk_get_enabled() helper instead of calling devm_clk_get() and then clk_prepare_enable(). It simplifies the error handling and makes the code more compact. Also use dev_err_probe() to handle possible -EPROBE_DEFER errors if the clock is not available yet. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
76536caabe
commit
81da8056e9
@ -134,32 +134,23 @@ static int exynos_trng_probe(struct platform_device *pdev)
|
||||
goto err_pm_get;
|
||||
}
|
||||
|
||||
trng->clk = devm_clk_get(&pdev->dev, "secss");
|
||||
trng->clk = devm_clk_get_enabled(&pdev->dev, "secss");
|
||||
if (IS_ERR(trng->clk)) {
|
||||
ret = PTR_ERR(trng->clk);
|
||||
dev_err(&pdev->dev, "Could not get clock.\n");
|
||||
goto err_clock;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(trng->clk);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Could not enable the clk.\n");
|
||||
ret = dev_err_probe(&pdev->dev, PTR_ERR(trng->clk),
|
||||
"Could not get clock\n");
|
||||
goto err_clock;
|
||||
}
|
||||
|
||||
ret = devm_hwrng_register(&pdev->dev, &trng->rng);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Could not register hwrng device.\n");
|
||||
goto err_register;
|
||||
goto err_clock;
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "Exynos True Random Number Generator.\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_register:
|
||||
clk_disable_unprepare(trng->clk);
|
||||
|
||||
err_clock:
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
|
||||
@ -171,10 +162,6 @@ err_pm_get:
|
||||
|
||||
static void exynos_trng_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct exynos_trng_dev *trng = platform_get_drvdata(pdev);
|
||||
|
||||
clk_disable_unprepare(trng->clk);
|
||||
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user