From ce7ee4e80a72d3b1009ca232be8981de93c015f6 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 8 May 2007 17:21:59 +0200 Subject: 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 Acked-by: Juerg Haefliger --- drivers/hwmon/vt1211.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/hwmon/vt1211.c') diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c index 89c23d6add7..9f3e332c5b7 100644 --- a/drivers/hwmon/vt1211.c +++ b/drivers/hwmon/vt1211.c @@ -31,6 +31,7 @@ #include #include #include +#include #include static int uch_config = -1; @@ -1130,6 +1131,12 @@ static int __devinit vt1211_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!request_region(res->start, res->end - res->start + 1, DRVNAME)) { + err = -EBUSY; + dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", + (unsigned long)res->start, (unsigned long)res->end); + goto EXIT_KFREE; + } data->addr = res->start; data->name = DRVNAME; mutex_init(&data->update_lock); @@ -1197,6 +1204,8 @@ EXIT_DEV_REMOVE: dev_err(dev, "Sysfs interface creation failed (%d)\n", err); EXIT_DEV_REMOVE_SILENT: vt1211_remove_sysfs(pdev); + release_region(res->start, res->end - res->start + 1); +EXIT_KFREE: platform_set_drvdata(pdev, NULL); kfree(data); EXIT: @@ -1206,12 +1215,16 @@ EXIT: static int __devexit vt1211_remove(struct platform_device *pdev) { struct vt1211_data *data = platform_get_drvdata(pdev); + struct resource *res; hwmon_device_unregister(data->class_dev); vt1211_remove_sysfs(pdev); platform_set_drvdata(pdev, NULL); kfree(data); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + release_region(res->start, res->end - res->start + 1); + return 0; } -- cgit v1.2.3