Commit 6a2bc448 authored by Martin Kaiser's avatar Martin Kaiser Committed by Herbert Xu

hwrng: imx-rngc - use devm_clk_get_enabled

Use the new devm_clk_get_enabled function to get our clock.

We don't have to disable and unprepare the clock ourselves any more in
error paths and 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 6363d81b
...@@ -245,7 +245,7 @@ static int imx_rngc_probe(struct platform_device *pdev) ...@@ -245,7 +245,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (IS_ERR(rngc->base)) if (IS_ERR(rngc->base))
return PTR_ERR(rngc->base); return PTR_ERR(rngc->base);
rngc->clk = devm_clk_get(&pdev->dev, NULL); rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(rngc->clk)) { if (IS_ERR(rngc->clk)) {
dev_err(&pdev->dev, "Can not get rng_clk\n"); dev_err(&pdev->dev, "Can not get rng_clk\n");
return PTR_ERR(rngc->clk); return PTR_ERR(rngc->clk);
...@@ -255,26 +255,20 @@ static int imx_rngc_probe(struct platform_device *pdev) ...@@ -255,26 +255,20 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
ret = clk_prepare_enable(rngc->clk);
if (ret)
return ret;
ver_id = readl(rngc->base + RNGC_VER_ID); ver_id = readl(rngc->base + RNGC_VER_ID);
rng_type = ver_id >> RNGC_TYPE_SHIFT; rng_type = ver_id >> RNGC_TYPE_SHIFT;
/* /*
* This driver supports only RNGC and RNGB. (There's a different * This driver supports only RNGC and RNGB. (There's a different
* driver for RNGA.) * driver for RNGA.)
*/ */
if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB) { if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB)
ret = -ENODEV; return -ENODEV;
goto err;
}
ret = devm_request_irq(&pdev->dev, ret = devm_request_irq(&pdev->dev,
irq, imx_rngc_irq, 0, pdev->name, (void *)rngc); irq, imx_rngc_irq, 0, pdev->name, (void *)rngc);
if (ret) { if (ret) {
dev_err(rngc->dev, "Can't get interrupt working.\n"); dev_err(rngc->dev, "Can't get interrupt working.\n");
goto err; return ret;
} }
init_completion(&rngc->rng_op_done); init_completion(&rngc->rng_op_done);
...@@ -294,14 +288,14 @@ static int imx_rngc_probe(struct platform_device *pdev) ...@@ -294,14 +288,14 @@ static int imx_rngc_probe(struct platform_device *pdev)
ret = imx_rngc_self_test(rngc); ret = imx_rngc_self_test(rngc);
if (ret) { if (ret) {
dev_err(rngc->dev, "self test failed\n"); dev_err(rngc->dev, "self test failed\n");
goto err; return ret;
} }
} }
ret = hwrng_register(&rngc->rng); ret = hwrng_register(&rngc->rng);
if (ret) { if (ret) {
dev_err(&pdev->dev, "hwrng registration failed\n"); dev_err(&pdev->dev, "hwrng registration failed\n");
goto err; return ret;
} }
dev_info(&pdev->dev, dev_info(&pdev->dev,
...@@ -309,11 +303,6 @@ static int imx_rngc_probe(struct platform_device *pdev) ...@@ -309,11 +303,6 @@ static int imx_rngc_probe(struct platform_device *pdev)
rng_type == RNGC_TYPE_RNGB ? 'B' : 'C', rng_type == RNGC_TYPE_RNGB ? 'B' : 'C',
(ver_id >> RNGC_VER_MAJ_SHIFT) & 0xff, ver_id & 0xff); (ver_id >> RNGC_VER_MAJ_SHIFT) & 0xff, ver_id & 0xff);
return 0; return 0;
err:
clk_disable_unprepare(rngc->clk);
return ret;
} }
static int __exit imx_rngc_remove(struct platform_device *pdev) static int __exit imx_rngc_remove(struct platform_device *pdev)
...@@ -322,8 +311,6 @@ static int __exit imx_rngc_remove(struct platform_device *pdev) ...@@ -322,8 +311,6 @@ static int __exit imx_rngc_remove(struct platform_device *pdev)
hwrng_unregister(&rngc->rng); hwrng_unregister(&rngc->rng);
clk_disable_unprepare(rngc->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