Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / drivers / hwmon / w83627ehf.c
index d5aa25ce5dbdc8251d05d384391c418070f80d9b..cb808d0153619838378bd70f1ea5bfc3ca1c5ad2 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 #include "lm75.h"
 
@@ -59,6 +60,10 @@ static const char * w83627ehf_device_names[] = {
        "w83627dhg",
 };
 
+static unsigned short force_id;
+module_param(force_id, ushort, 0);
+MODULE_PARM_DESC(force_id, "Override the detected device ID");
+
 #define DRVNAME "w83627ehf"
 
 /*
@@ -498,7 +503,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
                }
 
                for (i = 0; i < 4; i++) {
-                       /* pwmcfg, tolarance mapped for i=0, i=1 to same reg */
+                       /* pwmcfg, tolerance mapped for i=0, i=1 to same reg */
                        if (i != 1) {
                                pwmcfg = w83627ehf_read_value(data,
                                                W83627EHF_REG_PWM_ENABLE[i]);
@@ -1198,8 +1203,7 @@ static void w83627ehf_device_remove_files(struct device *dev)
                device_remove_file(dev, &sda_temp[i].dev_attr);
 
        device_remove_file(dev, &dev_attr_name);
-       if (data->vid != 0x3f)
-               device_remove_file(dev, &dev_attr_cpu0_vid);
+       device_remove_file(dev, &dev_attr_cpu0_vid);
 }
 
 /* Get the monitoring functions started */
@@ -1299,11 +1303,16 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
                        }
                }
 
-               data->vid = superio_inb(sio_data->sioreg, SIO_REG_VID_DATA) & 0x3f;
+               data->vid = superio_inb(sio_data->sioreg, SIO_REG_VID_DATA);
+               if (sio_data->kind == w83627ehf) /* 6 VID pins only */
+                       data->vid &= 0x3f;
+
+               err = device_create_file(dev, &dev_attr_cpu0_vid);
+               if (err)
+                       goto exit_release;
        } else {
                dev_info(dev, "VID pins in output mode, CPU VID not "
                         "available\n");
-               data->vid = 0x3f;
        }
 
        /* fan4 and fan5 share some pins with the GPIO and serial flash */
@@ -1386,12 +1395,6 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
        if (err)
                goto exit_remove;
 
-       if (data->vid != 0x3f) {
-               err = device_create_file(dev, &dev_attr_cpu0_vid);
-               if (err)
-                       goto exit_remove;
-       }
-
        data->hwmon_dev = hwmon_device_register(dev);
        if (IS_ERR(data->hwmon_dev)) {
                err = PTR_ERR(data->hwmon_dev);
@@ -1445,8 +1448,11 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
 
        superio_enter(sioaddr);
 
-       val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
-           | superio_inb(sioaddr, SIO_REG_DEVID + 1);
+       if (force_id)
+               val = force_id;
+       else
+               val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
+                   | superio_inb(sioaddr, SIO_REG_DEVID + 1);
        switch (val & SIO_ID_MASK) {
        case SIO_W83627EHF_ID:
                sio_data->kind = w83627ehf;
@@ -1539,6 +1545,11 @@ static int __init sensors_w83627ehf_init(void)
        res.start = address + IOREGION_OFFSET;
        res.end = address + IOREGION_OFFSET + IOREGION_LENGTH - 1;
        res.flags = IORESOURCE_IO;
+
+       err = acpi_check_resource_conflict(&res);
+       if (err)
+               goto exit;
+
        err = platform_device_add_resources(pdev, &res, 1);
        if (err) {
                printk(KERN_ERR DRVNAME ": Device resource addition failed "