aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-07-08 01:04:55 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-07-08 01:48:14 -0400
commit72398e4b1a4cf55d3698a4f265b638093a470b04 (patch)
tree497fd88ccf5d3984b9585f52139e2e3b35bf8798
parent666cbe342622c959ad95515918a1c1f8210c93f2 (diff)
Input: use resource_size when allocating resources
Use the function resource_size, which reduces the chance of introducing off-by-one errors in calculating the resource size. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @@ struct resource *res; @@ - (res->end - res->start) + 1 + resource_size(res) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/misc/cobalt_btns.c2
-rw-r--r--drivers/input/serio/at32psif.c2
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c8
-rw-r--r--drivers/input/touchscreen/w90p910_ts.c8
4 files changed, 10 insertions, 10 deletions
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index 2adf9cb265da..d01da9bd5da4 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -116,7 +116,7 @@ static int __devinit cobalt_buttons_probe(struct platform_device *pdev)
116 } 116 }
117 117
118 bdev->poll_dev = poll_dev; 118 bdev->poll_dev = poll_dev;
119 bdev->reg = ioremap(res->start, res->end - res->start + 1); 119 bdev->reg = ioremap(res->start, resource_size(res));
120 dev_set_drvdata(&pdev->dev, bdev); 120 dev_set_drvdata(&pdev->dev, bdev);
121 121
122 error = input_register_polled_device(poll_dev); 122 error = input_register_polled_device(poll_dev);
diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c
index 41fda8c67b1e..a6fb7a3dcc46 100644
--- a/drivers/input/serio/at32psif.c
+++ b/drivers/input/serio/at32psif.c
@@ -231,7 +231,7 @@ static int __init psif_probe(struct platform_device *pdev)
231 goto out_free_io; 231 goto out_free_io;
232 } 232 }
233 233
234 psif->regs = ioremap(regs->start, regs->end - regs->start + 1); 234 psif->regs = ioremap(regs->start, resource_size(regs));
235 if (!psif->regs) { 235 if (!psif->regs) {
236 ret = -ENOMEM; 236 ret = -ENOMEM;
237 dev_dbg(&pdev->dev, "could not map I/O memory\n"); 237 dev_dbg(&pdev->dev, "could not map I/O memory\n");
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
index 055969e8be13..9c7fce4d74d0 100644
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -204,14 +204,14 @@ static int __devinit atmel_tsadcc_probe(struct platform_device *pdev)
204 goto err_free_dev; 204 goto err_free_dev;
205 } 205 }
206 206
207 if (!request_mem_region(res->start, res->end - res->start + 1, 207 if (!request_mem_region(res->start, resource_size(res),
208 "atmel tsadcc regs")) { 208 "atmel tsadcc regs")) {
209 dev_err(&pdev->dev, "resources is unavailable.\n"); 209 dev_err(&pdev->dev, "resources is unavailable.\n");
210 err = -EBUSY; 210 err = -EBUSY;
211 goto err_free_dev; 211 goto err_free_dev;
212 } 212 }
213 213
214 tsc_base = ioremap(res->start, res->end - res->start + 1); 214 tsc_base = ioremap(res->start, resource_size(res));
215 if (!tsc_base) { 215 if (!tsc_base) {
216 dev_err(&pdev->dev, "failed to map registers.\n"); 216 dev_err(&pdev->dev, "failed to map registers.\n");
217 err = -ENOMEM; 217 err = -ENOMEM;
@@ -286,7 +286,7 @@ err_free_irq:
286err_unmap_regs: 286err_unmap_regs:
287 iounmap(tsc_base); 287 iounmap(tsc_base);
288err_release_mem: 288err_release_mem:
289 release_mem_region(res->start, res->end - res->start + 1); 289 release_mem_region(res->start, resource_size(res));
290err_free_dev: 290err_free_dev:
291 input_free_device(ts_dev->input); 291 input_free_device(ts_dev->input);
292err_free_mem: 292err_free_mem:
@@ -305,7 +305,7 @@ static int __devexit atmel_tsadcc_remove(struct platform_device *pdev)
305 305
306 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 306 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
307 iounmap(tsc_base); 307 iounmap(tsc_base);
308 release_mem_region(res->start, res->end - res->start + 1); 308 release_mem_region(res->start, resource_size(res));
309 309
310 clk_disable(ts_dev->clk); 310 clk_disable(ts_dev->clk);
311 clk_put(ts_dev->clk); 311 clk_put(ts_dev->clk);
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c
index 6071f5882572..b3e782fdd2bb 100644
--- a/drivers/input/touchscreen/w90p910_ts.c
+++ b/drivers/input/touchscreen/w90p910_ts.c
@@ -241,13 +241,13 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
241 goto fail1; 241 goto fail1;
242 } 242 }
243 243
244 if (!request_mem_region(res->start, res->end - res->start + 1, 244 if (!request_mem_region(res->start, resource_size(res),
245 pdev->name)) { 245 pdev->name)) {
246 err = -EBUSY; 246 err = -EBUSY;
247 goto fail1; 247 goto fail1;
248 } 248 }
249 249
250 w90p910_ts->ts_reg = ioremap(res->start, res->end - res->start + 1); 250 w90p910_ts->ts_reg = ioremap(res->start, resource_size(res));
251 if (!w90p910_ts->ts_reg) { 251 if (!w90p910_ts->ts_reg) {
252 err = -ENOMEM; 252 err = -ENOMEM;
253 goto fail2; 253 goto fail2;
@@ -296,7 +296,7 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
296 296
297fail4: free_irq(w90p910_ts->irq_num, w90p910_ts); 297fail4: free_irq(w90p910_ts->irq_num, w90p910_ts);
298fail3: iounmap(w90p910_ts->ts_reg); 298fail3: iounmap(w90p910_ts->ts_reg);
299fail2: release_mem_region(res->start, res->end - res->start + 1); 299fail2: release_mem_region(res->start, resource_size(res));
300fail1: input_free_device(input_dev); 300fail1: input_free_device(input_dev);
301 kfree(w90p910_ts); 301 kfree(w90p910_ts);
302 return err; 302 return err;
@@ -312,7 +312,7 @@ static int __devexit w90x900ts_remove(struct platform_device *pdev)
312 iounmap(w90p910_ts->ts_reg); 312 iounmap(w90p910_ts->ts_reg);
313 313
314 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 314 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
315 release_mem_region(res->start, res->end - res->start + 1); 315 release_mem_region(res->start, resource_size(res));
316 316
317 input_unregister_device(w90p910_ts->input); 317 input_unregister_device(w90p910_ts->input);
318 kfree(w90p910_ts); 318 kfree(w90p910_ts);