aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-06-06 04:48:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-06-06 04:48:02 -0400
commitc12f667e7563c2c0e0908c997900b91b41b23592 (patch)
treeadd57171404be906a87e03820d9e0e5f31d53238
parent0792644d22852f40c8ad16c4ba1fefd76aba5643 (diff)
parent942c1a927bf296fd64fd49f04c5a8f66bb14446b (diff)
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging: hwmon: (max6642): Better chip detection schema hwmon: (coretemp) Further relax temperature range checks hwmon: (coretemp) Fix TjMax detection for older CPUs hwmon: (coretemp) Relax target temperature range check hwmon: (max6642) Rename temp_fault sysfs attribute to temp2_fault
-rw-r--r--drivers/hwmon/coretemp.c23
-rw-r--r--drivers/hwmon/max6642.c22
2 files changed, 22 insertions, 23 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index de3d2465fe2..85e937984ff 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -296,7 +296,7 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
296 * If the TjMax is not plausible, an assumption 296 * If the TjMax is not plausible, an assumption
297 * will be used 297 * will be used
298 */ 298 */
299 if (val > 80 && val < 120) { 299 if (val) {
300 dev_info(dev, "TjMax is %d C.\n", val); 300 dev_info(dev, "TjMax is %d C.\n", val);
301 return val * 1000; 301 return val * 1000;
302 } 302 }
@@ -304,24 +304,9 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
304 304
305 /* 305 /*
306 * An assumption is made for early CPUs and unreadable MSR. 306 * An assumption is made for early CPUs and unreadable MSR.
307 * NOTE: the given value may not be correct. 307 * NOTE: the calculated value may not be correct.
308 */ 308 */
309 309 return adjust_tjmax(c, id, dev);
310 switch (c->x86_model) {
311 case 0xe:
312 case 0xf:
313 case 0x16:
314 case 0x1a:
315 dev_warn(dev, "TjMax is assumed as 100 C!\n");
316 return 100000;
317 case 0x17:
318 case 0x1c: /* Atom CPUs */
319 return adjust_tjmax(c, id, dev);
320 default:
321 dev_warn(dev, "CPU (model=0x%x) is not supported yet,"
322 " using default TjMax of 100C.\n", c->x86_model);
323 return 100000;
324 }
325} 310}
326 311
327static void __devinit get_ucode_rev_on_cpu(void *edx) 312static void __devinit get_ucode_rev_on_cpu(void *edx)
@@ -341,7 +326,7 @@ static int get_pkg_tjmax(unsigned int cpu, struct device *dev)
341 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); 326 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
342 if (!err) { 327 if (!err) {
343 val = (eax >> 16) & 0xff; 328 val = (eax >> 16) & 0xff;
344 if (val > 80 && val < 120) 329 if (val)
345 return val * 1000; 330 return val * 1000;
346 } 331 }
347 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu); 332 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);
diff --git a/drivers/hwmon/max6642.c b/drivers/hwmon/max6642.c
index 0f9fc40379c..e855d3b0bd1 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);
247static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, 261static 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);
249static SENSOR_DEVICE_ATTR(temp_fault, S_IRUGO, show_alarm, NULL, 2); 263static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
250static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); 264static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
251static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); 265static 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