Merge branch 'drm-forlinus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / drivers / hwmon / w83627hf.c
index 70ef926..7ea441d 100644 (file)
@@ -180,11 +180,10 @@ superio_exit(void)
 #define W83781D_REG_BANK 0x4E
 
 #define W83781D_REG_CONFIG 0x40
-#define W83781D_REG_ALARM1 0x41
-#define W83781D_REG_ALARM2 0x42
-#define W83781D_REG_ALARM3 0x450
+#define W83781D_REG_ALARM1 0x459
+#define W83781D_REG_ALARM2 0x45A
+#define W83781D_REG_ALARM3 0x45B
 
-#define W83781D_REG_IRQ 0x4C
 #define W83781D_REG_BEEP_CONFIG 0x4D
 #define W83781D_REG_BEEP_INTS1 0x56
 #define W83781D_REG_BEEP_INTS2 0x57
@@ -333,8 +332,9 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev);
 static void w83627hf_init_client(struct i2c_client *client);
 
 static struct i2c_driver w83627hf_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "w83627hf",
+       .driver = {
+               .name   = "w83627hf",
+       },
        .attach_adapter = w83627hf_detect,
        .detach_client  = w83627hf_detach_client,
 };
@@ -457,7 +457,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
                (w83627thf == data->type || w83637hf == data->type))
 
                /* use VRM9 calculation */
-               data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+               data->in_min[0] =
+                       SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
+                                       255);
        else
                /* use VRM8 (standard) calculation */
                data->in_min[0] = IN_TO_REG(val);
@@ -482,7 +484,9 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
                (w83627thf == data->type || w83637hf == data->type))
                
                /* use VRM9 calculation */
-               data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+               data->in_max[0] =
+                       SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
+                                       255);
        else
                /* use VRM8 (standard) calculation */
                data->in_max[0] = IN_TO_REG(val);
@@ -1006,7 +1010,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
                address = force_addr & WINB_ALIGNMENT;
 
        if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE,
-                           w83627hf_driver.name)) {
+                           w83627hf_driver.driver.name)) {
                err = -EBUSY;
                goto ERROR0;
        }
@@ -1119,11 +1123,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
        if (kind != w83697hf)
                device_create_file_temp(new_client, 3);
 
-       if (kind != w83697hf)
+       if (kind != w83697hf && data->vid != 0xff) {
                device_create_file_vid(new_client);
-
-       if (kind != w83697hf)
                device_create_file_vrm(new_client);
+       }
 
        device_create_file_fan_div(new_client, 1);
        device_create_file_fan_div(new_client, 2);
@@ -1229,7 +1232,7 @@ static int w83627thf_read_gpio5(struct i2c_client *client)
 
        /* Make sure the pins are configured for input
           There must be at least five (VRM 9), and possibly 6 (VRM 10) */
-       sel = superio_inb(W83627THF_GPIO5_IOSR);
+       sel = superio_inb(W83627THF_GPIO5_IOSR) & 0x3f;
        if ((sel & 0x1f) != 0x1f) {
                dev_dbg(&client->dev, "GPIO5 not configured for VID "
                        "function\n");
@@ -1320,19 +1323,18 @@ static void w83627hf_init_client(struct i2c_client *client)
                int hi = w83627hf_read_value(client, W83781D_REG_CHIPID);
                data->vid = (lo & 0x0f) | ((hi & 0x01) << 4);
        } else if (w83627thf == data->type) {
-               data->vid = w83627thf_read_gpio5(client) & 0x3f;
+               data->vid = w83627thf_read_gpio5(client);
        }
 
        /* Read VRM & OVT Config only once */
        if (w83627thf == data->type || w83637hf == data->type) {
                data->vrm_ovt = 
                        w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
-               data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
-       } else {
-               /* Convert VID to voltage based on default VRM */
-               data->vrm = vid_which_vrm();
        }
 
+       /* Convert VID to voltage based on VRM */
+       data->vrm = vid_which_vrm();
+
        tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
        for (i = 1; i <= 3; i++) {
                if (!(tmp & BIT_SCFG1[i - 1])) {
@@ -1370,13 +1372,6 @@ static void w83627hf_init_client(struct i2c_client *client)
                                        W83781D_REG_TEMP3_CONFIG, tmp & 0xfe);
                        }
                }
-
-               /* enable comparator mode for temp2 and temp3 so
-                  alarm indication will work correctly */
-               i = w83627hf_read_value(client, W83781D_REG_IRQ);
-               if (!(i & 0x40))
-                       w83627hf_write_value(client, W83781D_REG_IRQ,
-                                           i | 0x40);
        }
 
        /* Start monitoring */
@@ -1400,7 +1395,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
                        /* skip missing sensors */
                        if (((data->type == w83697hf) && (i == 1)) ||
                            ((data->type == w83627thf || data->type == w83637hf)
-                           && (i == 4 || i == 5)))
+                           && (i == 5 || i == 6)))
                                continue;
                        data->in[i] =
                            w83627hf_read_value(client, W83781D_REG_IN(i));