From ed5e079edf2cf4446718af0f5c6ccf51d2e65827 Mon Sep 17 00:00:00 2001 From: DrSamJames Date: Tue, 24 Nov 2026 19:00:48 +0000 Subject: [PATCH] iio: adc: nvt_adc: report the thermal zone in millidegrees thermal_get_temp() returns whole degrees Celsius, but the thermal sysfs ABI (/sys/class/thermal/thermal_zone*/temp) and every in-kernel user of thermal_zone_get_temp() expect millidegrees. Userspace reading the nvt_thermal zone therefore sees 51 instead of 51000, i.e. 0.051 C. Keep the same calibration (1.319 C per ADC step on NA51089, 1.3 C on NA51055, 30 C at the OTP trim level) and scale it to millidegrees. This also drops the integer division, so the reading keeps its sub-degree resolution. Nothing in the tree consumes the "nvt_thermal" zone in degrees. Tested on NA51089 (NT98566). NA51055 is untested. Signed-off-by: DrSamJames --- drivers/iio/adc/nvt_adc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/nvt_adc.c b/drivers/iio/adc/nvt_adc.c index f1358c67921..a706ba99fdb 100644 --- a/drivers/iio/adc/nvt_adc.c +++ b/drivers/iio/adc/nvt_adc.c @@ -338,13 +338,11 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) thermal_reg.reg = adc_getreg(adc, THERMAL_SENSOR_CONFIGURE_REG_OFS); temp_value = thermal_reg.bit.ain_avg_out; - if (nvt_get_chip_id() == CHIP_NA51055) { - *temp = (temp_value - adc->trim_value)*13; - *temp = *temp/10 + 30; - } else { - *temp = (temp_value - adc->trim_value)*1319; - *temp = *temp/1000 + 30; - } + /* The thermal sysfs ABI reports millidegrees Celsius. */ + if (nvt_get_chip_id() == CHIP_NA51055) + *temp = (temp_value - adc->trim_value) * 1300 + 30000; + else + *temp = (temp_value - adc->trim_value) * 1319 + 30000; return 0; }