aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2014-02-27 00:06:31 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2014-03-10 08:13:37 -0400
commit1655c24095da0b13bbd7a80b25948b19f6efdb37 (patch)
tree2243b06c34d198bd1f0d6a4cbff0f7a95a05b28a
parent0c0aa8446433849f19761ebb7cd2f58fde387a04 (diff)
hwrng: nomadik - Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/char/hw_random/nomadik-rng.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
index 232b87fb5fc9..bc904bb3f8a2 100644
--- a/drivers/char/hw_random/nomadik-rng.c
+++ b/drivers/char/hw_random/nomadik-rng.c
@@ -44,7 +44,7 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
44 void __iomem *base; 44 void __iomem *base;
45 int ret; 45 int ret;
46 46
47 rng_clk = clk_get(&dev->dev, NULL); 47 rng_clk = devm_clk_get(&dev->dev, NULL);
48 if (IS_ERR(rng_clk)) { 48 if (IS_ERR(rng_clk)) {
49 dev_err(&dev->dev, "could not get rng clock\n"); 49 dev_err(&dev->dev, "could not get rng clock\n");
50 ret = PTR_ERR(rng_clk); 50 ret = PTR_ERR(rng_clk);
@@ -57,33 +57,28 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
57 if (ret) 57 if (ret)
58 goto out_clk; 58 goto out_clk;
59 ret = -ENOMEM; 59 ret = -ENOMEM;
60 base = ioremap(dev->res.start, resource_size(&dev->res)); 60 base = devm_ioremap(&dev->dev, dev->res.start,
61 resource_size(&dev->res));
61 if (!base) 62 if (!base)
62 goto out_release; 63 goto out_release;
63 nmk_rng.priv = (unsigned long)base; 64 nmk_rng.priv = (unsigned long)base;
64 ret = hwrng_register(&nmk_rng); 65 ret = hwrng_register(&nmk_rng);
65 if (ret) 66 if (ret)
66 goto out_unmap; 67 goto out_release;
67 return 0; 68 return 0;
68 69
69out_unmap:
70 iounmap(base);
71out_release: 70out_release:
72 amba_release_regions(dev); 71 amba_release_regions(dev);
73out_clk: 72out_clk:
74 clk_disable(rng_clk); 73 clk_disable(rng_clk);
75 clk_put(rng_clk);
76 return ret; 74 return ret;
77} 75}
78 76
79static int nmk_rng_remove(struct amba_device *dev) 77static int nmk_rng_remove(struct amba_device *dev)
80{ 78{
81 void __iomem *base = (void __iomem *)nmk_rng.priv;
82 hwrng_unregister(&nmk_rng); 79 hwrng_unregister(&nmk_rng);
83 iounmap(base);
84 amba_release_regions(dev); 80 amba_release_regions(dev);
85 clk_disable(rng_clk); 81 clk_disable(rng_clk);
86 clk_put(rng_clk);
87 return 0; 82 return 0;
88} 83}
89 84