Commit e4ab6e72 authored by Martin Kaiser's avatar Martin Kaiser Committed by Herbert Xu

hwrng: ingenic - use devm_clk_get_enabled

Use devm_clk_get_enabled in the ingenic-trng driver. We don't have to
disable and unprepare the clock any more in error paths or in the remove
function.
Signed-off-by: default avatarMartin Kaiser <martin@kaiser.cx>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 099f2368
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
struct ingenic_trng { struct ingenic_trng {
void __iomem *base; void __iomem *base;
struct clk *clk;
struct hwrng rng; struct hwrng rng;
}; };
...@@ -77,6 +76,7 @@ static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait ...@@ -77,6 +76,7 @@ static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait
static int ingenic_trng_probe(struct platform_device *pdev) static int ingenic_trng_probe(struct platform_device *pdev)
{ {
struct ingenic_trng *trng; struct ingenic_trng *trng;
struct clk *clk;
int ret; int ret;
trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
...@@ -89,16 +89,10 @@ static int ingenic_trng_probe(struct platform_device *pdev) ...@@ -89,16 +89,10 @@ static int ingenic_trng_probe(struct platform_device *pdev)
return PTR_ERR(trng->base); return PTR_ERR(trng->base);
} }
trng->clk = devm_clk_get(&pdev->dev, NULL); clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(trng->clk)) { if (IS_ERR(clk)) {
pr_crit("%s: Cannot get DTRNG clock\n", __func__); pr_crit("%s: Cannot get and enable DTRNG clock\n", __func__);
return PTR_ERR(trng->clk); return PTR_ERR(clk);
}
ret = clk_prepare_enable(trng->clk);
if (ret) {
pr_crit("%s: Unable to enable DTRNG clock\n", __func__);
return ret;
} }
trng->rng.name = pdev->name; trng->rng.name = pdev->name;
...@@ -109,17 +103,13 @@ static int ingenic_trng_probe(struct platform_device *pdev) ...@@ -109,17 +103,13 @@ static int ingenic_trng_probe(struct platform_device *pdev)
ret = hwrng_register(&trng->rng); ret = hwrng_register(&trng->rng);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to register hwrng\n"); dev_err(&pdev->dev, "Failed to register hwrng\n");
goto err_unprepare_clk; return ret;
} }
platform_set_drvdata(pdev, trng); platform_set_drvdata(pdev, trng);
dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n"); dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
return 0; return 0;
err_unprepare_clk:
clk_disable_unprepare(trng->clk);
return ret;
} }
static int ingenic_trng_remove(struct platform_device *pdev) static int ingenic_trng_remove(struct platform_device *pdev)
...@@ -133,8 +123,6 @@ static int ingenic_trng_remove(struct platform_device *pdev) ...@@ -133,8 +123,6 @@ static int ingenic_trng_remove(struct platform_device *pdev)
ctrl &= ~CFG_GEN_EN; ctrl &= ~CFG_GEN_EN;
writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET); writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET);
clk_disable_unprepare(trng->clk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment