diff options
author | Julia Lawall <julia@diku.dk> | 2011-02-15 21:05:54 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2011-02-15 21:05:54 -0500 |
commit | c652759b6a27be04ef5d747d81e8c36cde7f55d1 (patch) | |
tree | 646ef54e6d9970a91a855bc2883359711c71093b /drivers/char | |
parent | fc9044e2db8c13746cd886d6276028b27ed5c78e (diff) |
hwrng: omap - Convert release_resource to release_region/release_mem_region
Request_region should be used with release_region, not release_resource.
The local variable mem, storing the result of request_mem_region, is
dropped and instead the pointer res is stored in the drvdata field of the
platform device. This information is retrieved in omap_rng_remove to
release the region. The drvdata field is not used elsewhere.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,E;
@@
(
*x = request_region(...)
|
*x = request_mem_region(...)
)
... when != release_region(x)
when != x = E
* release_resource(x);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/omap-rng.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index 06aad0831c73..2cc755a64302 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c | |||
@@ -91,7 +91,7 @@ static struct hwrng omap_rng_ops = { | |||
91 | 91 | ||
92 | static int __devinit omap_rng_probe(struct platform_device *pdev) | 92 | static int __devinit omap_rng_probe(struct platform_device *pdev) |
93 | { | 93 | { |
94 | struct resource *res, *mem; | 94 | struct resource *res; |
95 | int ret; | 95 | int ret; |
96 | 96 | ||
97 | /* | 97 | /* |
@@ -116,14 +116,12 @@ static int __devinit omap_rng_probe(struct platform_device *pdev) | |||
116 | if (!res) | 116 | if (!res) |
117 | return -ENOENT; | 117 | return -ENOENT; |
118 | 118 | ||
119 | mem = request_mem_region(res->start, resource_size(res), | 119 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { |
120 | pdev->name); | ||
121 | if (mem == NULL) { | ||
122 | ret = -EBUSY; | 120 | ret = -EBUSY; |
123 | goto err_region; | 121 | goto err_region; |
124 | } | 122 | } |
125 | 123 | ||
126 | dev_set_drvdata(&pdev->dev, mem); | 124 | dev_set_drvdata(&pdev->dev, res); |
127 | rng_base = ioremap(res->start, resource_size(res)); | 125 | rng_base = ioremap(res->start, resource_size(res)); |
128 | if (!rng_base) { | 126 | if (!rng_base) { |
129 | ret = -ENOMEM; | 127 | ret = -ENOMEM; |
@@ -146,7 +144,7 @@ err_register: | |||
146 | iounmap(rng_base); | 144 | iounmap(rng_base); |
147 | rng_base = NULL; | 145 | rng_base = NULL; |
148 | err_ioremap: | 146 | err_ioremap: |
149 | release_resource(mem); | 147 | release_mem_region(res->start, resource_size(res)); |
150 | err_region: | 148 | err_region: |
151 | if (cpu_is_omap24xx()) { | 149 | if (cpu_is_omap24xx()) { |
152 | clk_disable(rng_ick); | 150 | clk_disable(rng_ick); |
@@ -157,7 +155,7 @@ err_region: | |||
157 | 155 | ||
158 | static int __exit omap_rng_remove(struct platform_device *pdev) | 156 | static int __exit omap_rng_remove(struct platform_device *pdev) |
159 | { | 157 | { |
160 | struct resource *mem = dev_get_drvdata(&pdev->dev); | 158 | struct resource *res = dev_get_drvdata(&pdev->dev); |
161 | 159 | ||
162 | hwrng_unregister(&omap_rng_ops); | 160 | hwrng_unregister(&omap_rng_ops); |
163 | 161 | ||
@@ -170,7 +168,7 @@ static int __exit omap_rng_remove(struct platform_device *pdev) | |||
170 | clk_put(rng_ick); | 168 | clk_put(rng_ick); |
171 | } | 169 | } |
172 | 170 | ||
173 | release_resource(mem); | 171 | release_mem_region(res->start, resource_size(res)); |
174 | rng_base = NULL; | 172 | rng_base = NULL; |
175 | 173 | ||
176 | return 0; | 174 | return 0; |