diff options
Diffstat (limited to 'drivers/hwmon/max6642.c')
-rw-r--r-- | drivers/hwmon/max6642.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/hwmon/max6642.c b/drivers/hwmon/max6642.c index 0f9fc40379cd..e855d3b0bd1f 100644 --- a/drivers/hwmon/max6642.c +++ b/drivers/hwmon/max6642.c | |||
@@ -136,15 +136,29 @@ static int max6642_detect(struct i2c_client *client, | |||
136 | if (man_id != 0x4D) | 136 | if (man_id != 0x4D) |
137 | return -ENODEV; | 137 | return -ENODEV; |
138 | 138 | ||
139 | /* sanity check */ | ||
140 | if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D | ||
141 | || i2c_smbus_read_byte_data(client, 0x06) != 0x4D | ||
142 | || i2c_smbus_read_byte_data(client, 0xff) != 0x4D) | ||
143 | return -ENODEV; | ||
144 | |||
139 | /* | 145 | /* |
140 | * We read the config and status register, the 4 lower bits in the | 146 | * We read the config and status register, the 4 lower bits in the |
141 | * config register should be zero and bit 5, 3, 1 and 0 should be | 147 | * config register should be zero and bit 5, 3, 1 and 0 should be |
142 | * zero in the status register. | 148 | * zero in the status register. |
143 | */ | 149 | */ |
144 | reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG); | 150 | reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG); |
151 | if ((reg_config & 0x0f) != 0x00) | ||
152 | return -ENODEV; | ||
153 | |||
154 | /* in between, another round of sanity checks */ | ||
155 | if (i2c_smbus_read_byte_data(client, 0x04) != reg_config | ||
156 | || i2c_smbus_read_byte_data(client, 0x06) != reg_config | ||
157 | || i2c_smbus_read_byte_data(client, 0xff) != reg_config) | ||
158 | return -ENODEV; | ||
159 | |||
145 | reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS); | 160 | reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS); |
146 | if (((reg_config & 0x0f) != 0x00) || | 161 | if ((reg_status & 0x2b) != 0x00) |
147 | ((reg_status & 0x2b) != 0x00)) | ||
148 | return -ENODEV; | 162 | return -ENODEV; |
149 | 163 | ||
150 | strlcpy(info->type, "max6642", I2C_NAME_SIZE); | 164 | strlcpy(info->type, "max6642", I2C_NAME_SIZE); |
@@ -246,7 +260,7 @@ static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, | |||
246 | set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH); | 260 | set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH); |
247 | static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, | 261 | static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, |
248 | set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH); | 262 | set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH); |
249 | static SENSOR_DEVICE_ATTR(temp_fault, S_IRUGO, show_alarm, NULL, 2); | 263 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
250 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | 264 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); |
251 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); | 265 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
252 | 266 | ||
@@ -256,7 +270,7 @@ static struct attribute *max6642_attributes[] = { | |||
256 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 270 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
257 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 271 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
258 | 272 | ||
259 | &sensor_dev_attr_temp_fault.dev_attr.attr, | 273 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
260 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | 274 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, |
261 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, | 275 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, |
262 | NULL | 276 | NULL |