aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-09-15 11:18:13 -0400
committerJean Delvare <khali@linux-fr.org>2009-09-15 11:18:13 -0400
commit86855b0c1fd75338c67cabbf85d64d033612c47b (patch)
tree69b20b9059bc9d317fcb68a77ce988acce8577ef /drivers/hwmon
parent6055fae8aceee41471edfd1876e5617d16e028fe (diff)
hwmon: Use resource_size
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: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pc87427.c6
-rw-r--r--drivers/hwmon/vt1211.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
index 4e0de0e06d78..3170b26d2443 100644
--- a/drivers/hwmon/pc87427.c
+++ b/drivers/hwmon/pc87427.c
@@ -435,7 +435,7 @@ static int __devinit pc87427_probe(struct platform_device *pdev)
435 /* This will need to be revisited when we add support for 435 /* This will need to be revisited when we add support for
436 temperature and voltage monitoring. */ 436 temperature and voltage monitoring. */
437 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 437 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
438 if (!request_region(res->start, res->end - res->start + 1, DRVNAME)) { 438 if (!request_region(res->start, resource_size(res), DRVNAME)) {
439 err = -EBUSY; 439 err = -EBUSY;
440 dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n", 440 dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n",
441 (unsigned long)res->start, (unsigned long)res->end); 441 (unsigned long)res->start, (unsigned long)res->end);
@@ -475,7 +475,7 @@ exit_remove_files:
475 sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); 475 sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]);
476 } 476 }
477exit_release_region: 477exit_release_region:
478 release_region(res->start, res->end - res->start + 1); 478 release_region(res->start, resource_size(res));
479exit_kfree: 479exit_kfree:
480 platform_set_drvdata(pdev, NULL); 480 platform_set_drvdata(pdev, NULL);
481 kfree(data); 481 kfree(data);
@@ -500,7 +500,7 @@ static int __devexit pc87427_remove(struct platform_device *pdev)
500 kfree(data); 500 kfree(data);
501 501
502 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 502 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
503 release_region(res->start, res->end - res->start + 1); 503 release_region(res->start, resource_size(res));
504 504
505 return 0; 505 return 0;
506} 506}
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index 120b5d6dbd33..ae33bbb577c7 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -1136,7 +1136,7 @@ static int __devinit vt1211_probe(struct platform_device *pdev)
1136 } 1136 }
1137 1137
1138 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1138 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1139 if (!request_region(res->start, res->end - res->start + 1, DRVNAME)) { 1139 if (!request_region(res->start, resource_size(res), DRVNAME)) {
1140 err = -EBUSY; 1140 err = -EBUSY;
1141 dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", 1141 dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
1142 (unsigned long)res->start, (unsigned long)res->end); 1142 (unsigned long)res->start, (unsigned long)res->end);
@@ -1209,7 +1209,7 @@ EXIT_DEV_REMOVE:
1209 dev_err(dev, "Sysfs interface creation failed (%d)\n", err); 1209 dev_err(dev, "Sysfs interface creation failed (%d)\n", err);
1210EXIT_DEV_REMOVE_SILENT: 1210EXIT_DEV_REMOVE_SILENT:
1211 vt1211_remove_sysfs(pdev); 1211 vt1211_remove_sysfs(pdev);
1212 release_region(res->start, res->end - res->start + 1); 1212 release_region(res->start, resource_size(res));
1213EXIT_KFREE: 1213EXIT_KFREE:
1214 platform_set_drvdata(pdev, NULL); 1214 platform_set_drvdata(pdev, NULL);
1215 kfree(data); 1215 kfree(data);
@@ -1228,7 +1228,7 @@ static int __devexit vt1211_remove(struct platform_device *pdev)
1228 kfree(data); 1228 kfree(data);
1229 1229
1230 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1230 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1231 release_region(res->start, res->end - res->start + 1); 1231 release_region(res->start, resource_size(res));
1232 1232
1233 return 0; 1233 return 0;
1234} 1234}