Commit 1655c240 authored by Jingoo Han's avatar Jingoo Han Committed by Herbert Xu

hwrng: nomadik - Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0c0aa844
...@@ -44,7 +44,7 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -44,7 +44,7 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
void __iomem *base; void __iomem *base;
int ret; int ret;
rng_clk = clk_get(&dev->dev, NULL); rng_clk = devm_clk_get(&dev->dev, NULL);
if (IS_ERR(rng_clk)) { if (IS_ERR(rng_clk)) {
dev_err(&dev->dev, "could not get rng clock\n"); dev_err(&dev->dev, "could not get rng clock\n");
ret = PTR_ERR(rng_clk); ret = PTR_ERR(rng_clk);
...@@ -57,33 +57,28 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -57,33 +57,28 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
if (ret) if (ret)
goto out_clk; goto out_clk;
ret = -ENOMEM; ret = -ENOMEM;
base = ioremap(dev->res.start, resource_size(&dev->res)); base = devm_ioremap(&dev->dev, dev->res.start,
resource_size(&dev->res));
if (!base) if (!base)
goto out_release; goto out_release;
nmk_rng.priv = (unsigned long)base; nmk_rng.priv = (unsigned long)base;
ret = hwrng_register(&nmk_rng); ret = hwrng_register(&nmk_rng);
if (ret) if (ret)
goto out_unmap; goto out_release;
return 0; return 0;
out_unmap:
iounmap(base);
out_release: out_release:
amba_release_regions(dev); amba_release_regions(dev);
out_clk: out_clk:
clk_disable(rng_clk); clk_disable(rng_clk);
clk_put(rng_clk);
return ret; return ret;
} }
static int nmk_rng_remove(struct amba_device *dev) static int nmk_rng_remove(struct amba_device *dev)
{ {
void __iomem *base = (void __iomem *)nmk_rng.priv;
hwrng_unregister(&nmk_rng); hwrng_unregister(&nmk_rng);
iounmap(base);
amba_release_regions(dev); amba_release_regions(dev);
clk_disable(rng_clk); clk_disable(rng_clk);
clk_put(rng_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