Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf164c58 authored by Jean Delvare's avatar Jean Delvare Committed by Guenter Roeck
Browse files

hwmon: (w83627ehf) Properly report thermal diode sensors



The w83627ehf driver is improperly reporting thermal diode sensors as
type 2, instead of 3. This caused "sensors" and possibly other
monitoring tools to report these sensors as "transistor" instead of
"thermal diode".

Furthermore, diode subtype selection (CPU vs. external) is only
supported by the original W83627EHF/EHG. All later models only support
CPU diode type, and some (NCT6776F) don't even have the register in
question so we should avoid reading from it.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: stable@kernel.org
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
parent 976d1676
Loading
Loading
Loading
Loading
+11 −4
Original line number Original line Diff line number Diff line
@@ -1715,7 +1715,8 @@ static void w83627ehf_device_remove_files(struct device *dev)
}
}


/* Get the monitoring functions started */
/* Get the monitoring functions started */
static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
						   enum kinds kind)
{
{
	int i;
	int i;
	u8 tmp, diode;
	u8 tmp, diode;
@@ -1746,10 +1747,16 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
		w83627ehf_write_value(data, W83627EHF_REG_VBAT, tmp | 0x01);
		w83627ehf_write_value(data, W83627EHF_REG_VBAT, tmp | 0x01);


	/* Get thermal sensor types */
	/* Get thermal sensor types */
	switch (kind) {
	case w83627ehf:
		diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
		diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
		break;
	default:
		diode = 0x70;
	}
	for (i = 0; i < 3; i++) {
	for (i = 0; i < 3; i++) {
		if ((tmp & (0x02 << i)))
		if ((tmp & (0x02 << i)))
			data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 2;
			data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3;
		else
		else
			data->temp_type[i] = 4; /* thermistor */
			data->temp_type[i] = 4; /* thermistor */
	}
	}
@@ -2016,7 +2023,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
	}
	}


	/* Initialize the chip */
	/* Initialize the chip */
	w83627ehf_init_device(data);
	w83627ehf_init_device(data, sio_data->kind);


	data->vrm = vid_which_vrm();
	data->vrm = vid_which_vrm();
	superio_enter(sio_data->sioreg);
	superio_enter(sio_data->sioreg);