aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/vt1211.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-05-08 11:21:59 -0400
committerJean Delvare <khali@hyperion.delvare>2007-05-08 11:21:59 -0400
commitce7ee4e80a72d3b1009ca232be8981de93c015f6 (patch)
treeb5160fd4a2b2276f7bd332f753b43f6d9752476b /drivers/hwmon/vt1211.c
parent00cb4739053fa0ce4594a7798a4095007a1c7c79 (diff)
hwmon: Request the I/O regions in platform drivers
My understanding of the resource management in the Linux 2.6 device driver model is that the devices should declare their resources, and then when a driver attaches to a device, it should request the resources it will be using, so as to mark them busy. This is how the PCI and PNP subsystems work, you can clearly see the two levels of resources (declaration and request) in /proc/ioports for these devices. So I believe that our platform hardware monitoring drivers should follow the same logic. At the moment, we only declare the resources but we do not request them. This patch adds the I/O region request and release calls. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh@gmail.com>
Diffstat (limited to 'drivers/hwmon/vt1211.c')
-rw-r--r--drivers/hwmon/vt1211.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index 89c23d6add7b..9f3e332c5b7f 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -31,6 +31,7 @@
31#include <linux/hwmon-vid.h> 31#include <linux/hwmon-vid.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/ioport.h>
34#include <asm/io.h> 35#include <asm/io.h>
35 36
36static int uch_config = -1; 37static int uch_config = -1;
@@ -1130,6 +1131,12 @@ static int __devinit vt1211_probe(struct platform_device *pdev)
1130 } 1131 }
1131 1132
1132 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1133 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1134 if (!request_region(res->start, res->end - res->start + 1, DRVNAME)) {
1135 err = -EBUSY;
1136 dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
1137 (unsigned long)res->start, (unsigned long)res->end);
1138 goto EXIT_KFREE;
1139 }
1133 data->addr = res->start; 1140 data->addr = res->start;
1134 data->name = DRVNAME; 1141 data->name = DRVNAME;
1135 mutex_init(&data->update_lock); 1142 mutex_init(&data->update_lock);
@@ -1197,6 +1204,8 @@ EXIT_DEV_REMOVE:
1197 dev_err(dev, "Sysfs interface creation failed (%d)\n", err); 1204 dev_err(dev, "Sysfs interface creation failed (%d)\n", err);
1198EXIT_DEV_REMOVE_SILENT: 1205EXIT_DEV_REMOVE_SILENT:
1199 vt1211_remove_sysfs(pdev); 1206 vt1211_remove_sysfs(pdev);
1207 release_region(res->start, res->end - res->start + 1);
1208EXIT_KFREE:
1200 platform_set_drvdata(pdev, NULL); 1209 platform_set_drvdata(pdev, NULL);
1201 kfree(data); 1210 kfree(data);
1202EXIT: 1211EXIT:
@@ -1206,12 +1215,16 @@ EXIT:
1206static int __devexit vt1211_remove(struct platform_device *pdev) 1215static int __devexit vt1211_remove(struct platform_device *pdev)
1207{ 1216{
1208 struct vt1211_data *data = platform_get_drvdata(pdev); 1217 struct vt1211_data *data = platform_get_drvdata(pdev);
1218 struct resource *res;
1209 1219
1210 hwmon_device_unregister(data->class_dev); 1220 hwmon_device_unregister(data->class_dev);
1211 vt1211_remove_sysfs(pdev); 1221 vt1211_remove_sysfs(pdev);
1212 platform_set_drvdata(pdev, NULL); 1222 platform_set_drvdata(pdev, NULL);
1213 kfree(data); 1223 kfree(data);
1214 1224
1225 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1226 release_region(res->start, res->end - res->start + 1);
1227
1215 return 0; 1228 return 0;
1216} 1229}
1217 1230