Skip to contentSkip to conversation

hwmon: (k10temp) Only apply temperature offset if result is positive

PATCH New Guenter Roeck 1 participant 1 message Feb 8, 2018

Subsystems (2)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (k10temp) Only apply temperature offset if result is positive

A user reports a really bad temperature on Ryzen 1950X.

k10temp-pci-00cb
Adapter: PCI adapter
temp1: +4294948.3°C (high = +70.0°C)

This will happen if the temperature reported by the chip is lower than the offset temperature. If that happens, let's report a temperature of 0 degrees C.

Fixes 1b50b776355f ("hwmon: (k10temp) Add support for temperature offsets")
---
 drivers/hwmon/k10temp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/k10temp.c +4 -1
index 06b4e1c78bd8..4c6594a4661d 100644
@@ -129,7 +129,10 @@ static ssize_t temp1_input_show(struct device *dev,
 
 	data->read_tempreg(data->pdev, &regval);
 	temp = (regval >> 21) * 125;
-	temp -= data->temp_offset;
+	if (temp > data->temp_offset)
+		temp -= data->temp_offset;
+	else
+		temp = 0;
 
 	return sprintf(buf, "%u\n", temp);
 }
Signature · 1 line
2.7.4