Skip to content

Commit c12f667

Browse files
committed
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
2 parents 0792644 + 942c1a9 commit c12f667

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

drivers/hwmon/coretemp.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -296,32 +296,17 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
296296
* If the TjMax is not plausible, an assumption
297297
* will be used
298298
*/
299-
if (val > 80 && val < 120) {
299+
if (val) {
300300
dev_info(dev, "TjMax is %d C.\n", val);
301301
return val * 1000;
302302
}
303303
}
304304

305305
/*
306306
* 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.
308308
*/
309-
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-
}
309+
return adjust_tjmax(c, id, dev);
325310
}
326311

327312
static void __devinit get_ucode_rev_on_cpu(void *edx)
@@ -341,7 +326,7 @@ static int get_pkg_tjmax(unsigned int cpu, struct device *dev)
341326
err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
342327
if (!err) {
343328
val = (eax >> 16) & 0xff;
344-
if (val > 80 && val < 120)
329+
if (val)
345330
return val * 1000;
346331
}
347332
dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);

drivers/hwmon/max6642.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,29 @@ static int max6642_detect(struct i2c_client *client,
136136
if (man_id != 0x4D)
137137
return -ENODEV;
138138

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+
139145
/*
140146
* We read the config and status register, the 4 lower bits in the
141147
* config register should be zero and bit 5, 3, 1 and 0 should be
142148
* zero in the status register.
143149
*/
144150
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+
145160
reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS);
146-
if (((reg_config & 0x0f) != 0x00) ||
147-
((reg_status & 0x2b) != 0x00))
161+
if ((reg_status & 0x2b) != 0x00)
148162
return -ENODEV;
149163

150164
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,
246260
set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH);
247261
static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,
248262
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);
250264
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
251265
static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
252266

@@ -256,7 +270,7 @@ static struct attribute *max6642_attributes[] = {
256270
&sensor_dev_attr_temp1_max.dev_attr.attr,
257271
&sensor_dev_attr_temp2_max.dev_attr.attr,
258272

259-
&sensor_dev_attr_temp_fault.dev_attr.attr,
273+
&sensor_dev_attr_temp2_fault.dev_attr.attr,
260274
&sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
261275
&sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
262276
NULL

0 commit comments

Comments
 (0)