diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2013-03-12 23:57:27 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-03-22 06:13:55 -0400 |
commit | 264878e6a7eb02841100beb0d999987ef3b5e17f (patch) | |
tree | 80652dfa169e06f2fba708337f4ce2995699c5c1 /drivers/char | |
parent | cb7d5662d7a13471eff81b25277a229d7173aabd (diff) |
hwrng: mxc-rnga - Use devm_ioremap_resource()
Using devm_ioremap_resource() can make the code cleaner and simpler.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/mxc-rnga.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c index f05d85713fd3..93fc74164ee6 100644 --- a/drivers/char/hw_random/mxc-rnga.c +++ b/drivers/char/hw_random/mxc-rnga.c | |||
@@ -142,7 +142,7 @@ static void mxc_rnga_cleanup(struct hwrng *rng) | |||
142 | static int __init mxc_rnga_probe(struct platform_device *pdev) | 142 | static int __init mxc_rnga_probe(struct platform_device *pdev) |
143 | { | 143 | { |
144 | int err = -ENODEV; | 144 | int err = -ENODEV; |
145 | struct resource *res, *mem; | 145 | struct resource *res; |
146 | struct mxc_rng *mxc_rng; | 146 | struct mxc_rng *mxc_rng; |
147 | 147 | ||
148 | mxc_rng = devm_kzalloc(&pdev->dev, sizeof(struct mxc_rng), | 148 | mxc_rng = devm_kzalloc(&pdev->dev, sizeof(struct mxc_rng), |
@@ -172,15 +172,9 @@ static int __init mxc_rnga_probe(struct platform_device *pdev) | |||
172 | goto err_region; | 172 | goto err_region; |
173 | } | 173 | } |
174 | 174 | ||
175 | mem = request_mem_region(res->start, resource_size(res), pdev->name); | 175 | mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res); |
176 | if (mem == NULL) { | 176 | if (IS_ERR(mxc_rng->mem)) { |
177 | err = -EBUSY; | 177 | err = PTR_ERR(mxc_rng->mem); |
178 | goto err_region; | ||
179 | } | ||
180 | |||
181 | mxc_rng->mem = ioremap(res->start, resource_size(res)); | ||
182 | if (!mxc_rng->mem) { | ||
183 | err = -ENOMEM; | ||
184 | goto err_ioremap; | 178 | goto err_ioremap; |
185 | } | 179 | } |
186 | 180 | ||
@@ -195,8 +189,6 @@ static int __init mxc_rnga_probe(struct platform_device *pdev) | |||
195 | return 0; | 189 | return 0; |
196 | 190 | ||
197 | err_ioremap: | 191 | err_ioremap: |
198 | release_mem_region(res->start, resource_size(res)); | ||
199 | |||
200 | err_region: | 192 | err_region: |
201 | clk_disable_unprepare(mxc_rng->clk); | 193 | clk_disable_unprepare(mxc_rng->clk); |
202 | 194 | ||
@@ -206,15 +198,10 @@ out: | |||
206 | 198 | ||
207 | static int __exit mxc_rnga_remove(struct platform_device *pdev) | 199 | static int __exit mxc_rnga_remove(struct platform_device *pdev) |
208 | { | 200 | { |
209 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
210 | struct mxc_rng *mxc_rng = platform_get_drvdata(pdev); | 201 | struct mxc_rng *mxc_rng = platform_get_drvdata(pdev); |
211 | 202 | ||
212 | hwrng_unregister(&mxc_rng->rng); | 203 | hwrng_unregister(&mxc_rng->rng); |
213 | 204 | ||
214 | iounmap(mxc_rng->mem); | ||
215 | |||
216 | release_mem_region(res->start, resource_size(res)); | ||
217 | |||
218 | clk_disable_unprepare(mxc_rng->clk); | 205 | clk_disable_unprepare(mxc_rng->clk); |
219 | 206 | ||
220 | return 0; | 207 | return 0; |