aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@stericsson.com>2009-06-13 18:20:36 -0400
committerBen Dooks <ben-linux@fluff.org>2009-06-16 17:42:16 -0400
commitc6ffddea36dd576b70dfbd10eb5d2b287b786dca (patch)
tree9849cac5ca77534e38b4cb3c35a09d980ae84ff3 /drivers/i2c
parent18904c0ecdf2cf22347da2adc4b273e9570333d8 (diff)
i2c: Use resource_size macro
This replace all instances in the i2c busses tree of res->end - res->start + 1 with the handy macro resource_size(res) from ioport.h (coming in from platform_device.h). This was created with a simple sed -i -e 's/\([a-z]*\)->end *- *[a-z]*->start *+ *1/resource_size(\1)/g' Then manually replacing the PXA redefiniton of the same kind of macro manually. Recompiled some ARM defconfigs I could find to make a rough test so it shouldn't break anything, though I couldn't see exactly which configs you need for all the drivers. Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-at91.c8
-rw-r--r--drivers/i2c/busses/i2c-au1550.c2
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c2
-rw-r--r--drivers/i2c/busses/i2c-highlander.c2
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c2
-rw-r--r--drivers/i2c/busses/i2c-ocores.c8
-rw-r--r--drivers/i2c/busses/i2c-omap.c2
-rw-r--r--drivers/i2c/busses/i2c-pca-platform.c10
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c8
-rw-r--r--drivers/i2c/busses/i2c-pxa.c9
-rw-r--r--drivers/i2c/busses/i2c-versatile.c6
11 files changed, 28 insertions, 31 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 67d9dc5b351b..06e1ecb4919f 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -200,10 +200,10 @@ static int __devinit at91_i2c_probe(struct platform_device *pdev)
200 if (!res) 200 if (!res)
201 return -ENXIO; 201 return -ENXIO;
202 202
203 if (!request_mem_region(res->start, res->end - res->start + 1, "at91_i2c")) 203 if (!request_mem_region(res->start, resource_size(res), "at91_i2c"))
204 return -EBUSY; 204 return -EBUSY;
205 205
206 twi_base = ioremap(res->start, res->end - res->start + 1); 206 twi_base = ioremap(res->start, resource_size(res));
207 if (!twi_base) { 207 if (!twi_base) {
208 rc = -ENOMEM; 208 rc = -ENOMEM;
209 goto fail0; 209 goto fail0;
@@ -252,7 +252,7 @@ fail2:
252fail1: 252fail1:
253 iounmap(twi_base); 253 iounmap(twi_base);
254fail0: 254fail0:
255 release_mem_region(res->start, res->end - res->start + 1); 255 release_mem_region(res->start, resource_size(res));
256 256
257 return rc; 257 return rc;
258} 258}
@@ -268,7 +268,7 @@ static int __devexit at91_i2c_remove(struct platform_device *pdev)
268 268
269 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 269 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
270 iounmap(twi_base); 270 iounmap(twi_base);
271 release_mem_region(res->start, res->end - res->start + 1); 271 release_mem_region(res->start, resource_size(res));
272 272
273 clk_disable(twi_clk); /* disable peripheral clock */ 273 clk_disable(twi_clk); /* disable peripheral clock */
274 clk_put(twi_clk); 274 clk_put(twi_clk);
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index f78ce523e3db..532828bc50e6 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -389,7 +389,7 @@ i2c_au1550_probe(struct platform_device *pdev)
389 goto out; 389 goto out;
390 } 390 }
391 391
392 priv->ioarea = request_mem_region(r->start, r->end - r->start + 1, 392 priv->ioarea = request_mem_region(r->start, resource_size(r),
393 pdev->name); 393 pdev->name);
394 if (!priv->ioarea) { 394 if (!priv->ioarea) {
395 ret = -EBUSY; 395 ret = -EBUSY;
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 9fb114c274af..b309ac2c3d5c 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -652,7 +652,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
652 goto out_error_get_res; 652 goto out_error_get_res;
653 } 653 }
654 654
655 iface->regs_base = ioremap(res->start, res->end - res->start + 1); 655 iface->regs_base = ioremap(res->start, resource_size(res));
656 if (iface->regs_base == NULL) { 656 if (iface->regs_base == NULL) {
657 dev_err(&pdev->dev, "Cannot map IO\n"); 657 dev_err(&pdev->dev, "Cannot map IO\n");
658 rc = -ENXIO; 658 rc = -ENXIO;
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
index e5a8dae4a289..87ecace415da 100644
--- a/drivers/i2c/busses/i2c-highlander.c
+++ b/drivers/i2c/busses/i2c-highlander.c
@@ -373,7 +373,7 @@ static int __devinit highlander_i2c_probe(struct platform_device *pdev)
373 if (unlikely(!dev)) 373 if (unlikely(!dev))
374 return -ENOMEM; 374 return -ENOMEM;
375 375
376 dev->base = ioremap_nocache(res->start, res->end - res->start + 1); 376 dev->base = ioremap_nocache(res->start, resource_size(res));
377 if (unlikely(!dev->base)) { 377 if (unlikely(!dev->base)) {
378 ret = -ENXIO; 378 ret = -ENXIO;
379 goto err; 379 goto err;
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 5a4945d1dba4..c3869d94ad42 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -469,7 +469,7 @@ mv64xxx_i2c_map_regs(struct platform_device *pd,
469 if (!r) 469 if (!r)
470 return -ENODEV; 470 return -ENODEV;
471 471
472 size = r->end - r->start + 1; 472 size = resource_size(r);
473 473
474 if (!request_mem_region(r->start, size, drv_data->adapter.name)) 474 if (!request_mem_region(r->start, size, drv_data->adapter.name))
475 return -EBUSY; 475 return -EBUSY;
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 3542c6ba98f1..0dabe643ec51 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -234,14 +234,14 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
234 if (!i2c) 234 if (!i2c)
235 return -ENOMEM; 235 return -ENOMEM;
236 236
237 if (!request_mem_region(res->start, res->end - res->start + 1, 237 if (!request_mem_region(res->start, resource_size(res),
238 pdev->name)) { 238 pdev->name)) {
239 dev_err(&pdev->dev, "Memory region busy\n"); 239 dev_err(&pdev->dev, "Memory region busy\n");
240 ret = -EBUSY; 240 ret = -EBUSY;
241 goto request_mem_failed; 241 goto request_mem_failed;
242 } 242 }
243 243
244 i2c->base = ioremap(res->start, res->end - res->start + 1); 244 i2c->base = ioremap(res->start, resource_size(res));
245 if (!i2c->base) { 245 if (!i2c->base) {
246 dev_err(&pdev->dev, "Unable to map registers\n"); 246 dev_err(&pdev->dev, "Unable to map registers\n");
247 ret = -EIO; 247 ret = -EIO;
@@ -283,7 +283,7 @@ add_adapter_failed:
283request_irq_failed: 283request_irq_failed:
284 iounmap(i2c->base); 284 iounmap(i2c->base);
285map_failed: 285map_failed:
286 release_mem_region(res->start, res->end - res->start + 1); 286 release_mem_region(res->start, resource_size(res));
287request_mem_failed: 287request_mem_failed:
288 kfree(i2c); 288 kfree(i2c);
289 289
@@ -311,7 +311,7 @@ static int __devexit ocores_i2c_remove(struct platform_device* pdev)
311 311
312 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 312 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
313 if (res) 313 if (res)
314 release_mem_region(res->start, res->end - res->start + 1); 314 release_mem_region(res->start, resource_size(res));
315 315
316 kfree(i2c); 316 kfree(i2c);
317 317
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index c73475dd0fba..b606db85525d 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -828,7 +828,7 @@ omap_i2c_probe(struct platform_device *pdev)
828 dev->idle = 1; 828 dev->idle = 1;
829 dev->dev = &pdev->dev; 829 dev->dev = &pdev->dev;
830 dev->irq = irq->start; 830 dev->irq = irq->start;
831 dev->base = ioremap(mem->start, mem->end - mem->start + 1); 831 dev->base = ioremap(mem->start, resource_size(mem));
832 if (!dev->base) { 832 if (!dev->base) {
833 r = -ENOMEM; 833 r = -ENOMEM;
834 goto err_free_mem; 834 goto err_free_mem;
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 7b23891b7d59..c4df9d411cd5 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -27,8 +27,6 @@
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
30#define res_len(r) ((r)->end - (r)->start + 1)
31
32struct i2c_pca_pf_data { 30struct i2c_pca_pf_data {
33 void __iomem *reg_base; 31 void __iomem *reg_base;
34 int irq; /* if 0, use polling */ 32 int irq; /* if 0, use polling */
@@ -148,7 +146,7 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
148 goto e_print; 146 goto e_print;
149 } 147 }
150 148
151 if (!request_mem_region(res->start, res_len(res), res->name)) { 149 if (!request_mem_region(res->start, resource_size(res), res->name)) {
152 ret = -ENOMEM; 150 ret = -ENOMEM;
153 goto e_print; 151 goto e_print;
154 } 152 }
@@ -161,13 +159,13 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
161 159
162 init_waitqueue_head(&i2c->wait); 160 init_waitqueue_head(&i2c->wait);
163 161
164 i2c->reg_base = ioremap(res->start, res_len(res)); 162 i2c->reg_base = ioremap(res->start, resource_size(res));
165 if (!i2c->reg_base) { 163 if (!i2c->reg_base) {
166 ret = -ENOMEM; 164 ret = -ENOMEM;
167 goto e_remap; 165 goto e_remap;
168 } 166 }
169 i2c->io_base = res->start; 167 i2c->io_base = res->start;
170 i2c->io_size = res_len(res); 168 i2c->io_size = resource_size(res);
171 i2c->irq = irq; 169 i2c->irq = irq;
172 170
173 i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; 171 i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
@@ -250,7 +248,7 @@ e_reqirq:
250e_remap: 248e_remap:
251 kfree(i2c); 249 kfree(i2c);
252e_alloc: 250e_alloc:
253 release_mem_region(res->start, res_len(res)); 251 release_mem_region(res->start, resource_size(res));
254e_print: 252e_print:
255 printk(KERN_ERR "Registering PCA9564/PCA9665 FAILED! (%d)\n", ret); 253 printk(KERN_ERR "Registering PCA9564/PCA9665 FAILED! (%d)\n", ret);
256 return ret; 254 return ret;
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index 0bdb2d7f0570..7b57d5f267e1 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -283,7 +283,7 @@ static int __devinit pmcmsptwi_probe(struct platform_device *pldev)
283 } 283 }
284 284
285 /* reserve the memory region */ 285 /* reserve the memory region */
286 if (!request_mem_region(res->start, res->end - res->start + 1, 286 if (!request_mem_region(res->start, resource_size(res),
287 pldev->name)) { 287 pldev->name)) {
288 dev_err(&pldev->dev, 288 dev_err(&pldev->dev,
289 "Unable to get memory/io address region 0x%08x\n", 289 "Unable to get memory/io address region 0x%08x\n",
@@ -294,7 +294,7 @@ static int __devinit pmcmsptwi_probe(struct platform_device *pldev)
294 294
295 /* remap the memory */ 295 /* remap the memory */
296 pmcmsptwi_data.iobase = ioremap_nocache(res->start, 296 pmcmsptwi_data.iobase = ioremap_nocache(res->start,
297 res->end - res->start + 1); 297 resource_size(res));
298 if (!pmcmsptwi_data.iobase) { 298 if (!pmcmsptwi_data.iobase) {
299 dev_err(&pldev->dev, 299 dev_err(&pldev->dev,
300 "Unable to ioremap address 0x%08x\n", res->start); 300 "Unable to ioremap address 0x%08x\n", res->start);
@@ -360,7 +360,7 @@ ret_unmap:
360 iounmap(pmcmsptwi_data.iobase); 360 iounmap(pmcmsptwi_data.iobase);
361 361
362ret_unreserve: 362ret_unreserve:
363 release_mem_region(res->start, res->end - res->start + 1); 363 release_mem_region(res->start, resource_size(res));
364 364
365ret_err: 365ret_err:
366 return rc; 366 return rc;
@@ -385,7 +385,7 @@ static int __devexit pmcmsptwi_remove(struct platform_device *pldev)
385 iounmap(pmcmsptwi_data.iobase); 385 iounmap(pmcmsptwi_data.iobase);
386 386
387 res = platform_get_resource(pldev, IORESOURCE_MEM, 0); 387 res = platform_get_resource(pldev, IORESOURCE_MEM, 0);
388 release_mem_region(res->start, res->end - res->start + 1); 388 release_mem_region(res->start, resource_size(res));
389 389
390 return 0; 390 return 0;
391} 391}
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 035a6c7e59df..762e1e530882 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -993,7 +993,6 @@ static const struct i2c_algorithm i2c_pxa_pio_algorithm = {
993 .functionality = i2c_pxa_functionality, 993 .functionality = i2c_pxa_functionality,
994}; 994};
995 995
996#define res_len(r) ((r)->end - (r)->start + 1)
997static int i2c_pxa_probe(struct platform_device *dev) 996static int i2c_pxa_probe(struct platform_device *dev)
998{ 997{
999 struct pxa_i2c *i2c; 998 struct pxa_i2c *i2c;
@@ -1008,7 +1007,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1008 if (res == NULL || irq < 0) 1007 if (res == NULL || irq < 0)
1009 return -ENODEV; 1008 return -ENODEV;
1010 1009
1011 if (!request_mem_region(res->start, res_len(res), res->name)) 1010 if (!request_mem_region(res->start, resource_size(res), res->name))
1012 return -ENOMEM; 1011 return -ENOMEM;
1013 1012
1014 i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL); 1013 i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
@@ -1038,7 +1037,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1038 goto eclk; 1037 goto eclk;
1039 } 1038 }
1040 1039
1041 i2c->reg_base = ioremap(res->start, res_len(res)); 1040 i2c->reg_base = ioremap(res->start, resource_size(res));
1042 if (!i2c->reg_base) { 1041 if (!i2c->reg_base) {
1043 ret = -EIO; 1042 ret = -EIO;
1044 goto eremap; 1043 goto eremap;
@@ -1046,7 +1045,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1046 i2c->reg_shift = REG_SHIFT(id->driver_data); 1045 i2c->reg_shift = REG_SHIFT(id->driver_data);
1047 1046
1048 i2c->iobase = res->start; 1047 i2c->iobase = res->start;
1049 i2c->iosize = res_len(res); 1048 i2c->iosize = resource_size(res);
1050 1049
1051 i2c->irq = irq; 1050 i2c->irq = irq;
1052 1051
@@ -1110,7 +1109,7 @@ eremap:
1110eclk: 1109eclk:
1111 kfree(i2c); 1110 kfree(i2c);
1112emalloc: 1111emalloc:
1113 release_mem_region(res->start, res_len(res)); 1112 release_mem_region(res->start, resource_size(res));
1114 return ret; 1113 return ret;
1115} 1114}
1116 1115
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index fede619ba227..70de82163463 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -76,7 +76,7 @@ static int i2c_versatile_probe(struct platform_device *dev)
76 goto err_out; 76 goto err_out;
77 } 77 }
78 78
79 if (!request_mem_region(r->start, r->end - r->start + 1, "versatile-i2c")) { 79 if (!request_mem_region(r->start, resource_size(r), "versatile-i2c")) {
80 ret = -EBUSY; 80 ret = -EBUSY;
81 goto err_out; 81 goto err_out;
82 } 82 }
@@ -87,7 +87,7 @@ static int i2c_versatile_probe(struct platform_device *dev)
87 goto err_release; 87 goto err_release;
88 } 88 }
89 89
90 i2c->base = ioremap(r->start, r->end - r->start + 1); 90 i2c->base = ioremap(r->start, resource_size(r));
91 if (!i2c->base) { 91 if (!i2c->base) {
92 ret = -ENOMEM; 92 ret = -ENOMEM;
93 goto err_free; 93 goto err_free;
@@ -118,7 +118,7 @@ static int i2c_versatile_probe(struct platform_device *dev)
118 err_free: 118 err_free:
119 kfree(i2c); 119 kfree(i2c);
120 err_release: 120 err_release:
121 release_mem_region(r->start, r->end - r->start + 1); 121 release_mem_region(r->start, resource_size(r));
122 err_out: 122 err_out:
123 return ret; 123 return ret;
124} 124}