misc: nct1008: Reset current lo/hi limit values with register values
Lucas Dai [Tue, 8 Jan 2013 10:21:52 +0000 (18:21 +0800)]
To sync current lo/hi limit values with register values, reset current
lo/hi limit values with register values when sensor configuration.

Bug 1214568

Change-Id: I8f597f21d0fcfeb31b2b882c56ff7b5946c3cab2
Signed-off-by: Lucas Dai <lucasd@nvidia.com>
Reviewed-on: http://git-master/r/189501
Tested-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/misc/nct1008.c

index 5f604bc..6ea6745 100644 (file)
@@ -997,6 +997,21 @@ static int nct1008_configure_sensor(struct nct1008_data *data)
        if (err < 0)
                goto error;
 
+       /* Reset current hi/lo limit values with register values */
+       value = nct1008_read_reg(data->client, EXT_TEMP_LO_LIMIT_HI_BYTE_RD);
+       if (value < 0) {
+               err = value;
+               goto error;
+       }
+       data->current_lo_limit = value_to_temperature(pdata->ext_range, value);
+
+       value = nct1008_read_reg(data->client, EXT_TEMP_HI_LIMIT_HI_BYTE_RD);
+       if (value < 0) {
+               err = value;
+               goto error;
+       }
+       data->current_hi_limit = value_to_temperature(pdata->ext_range, value);
+
        return 0;
 error:
        dev_err(&client->dev, "\n exit %s, err=%d ", __func__, err);