drivers/thermal: Update state when temp is stable

Fix cooling state not decreasing error when the temperature is kept at low trip(stable, not dropping).

Test on "sim:thermal", log is from /proc/thermal/cpu-thermal and see thermal/thermal_dummy.c for trip point details.

e.g. The temperature decreasing from 71 to 65 and then kept.
       z:cpu-thermal t:71 t:1 h:16 l:0 c:fan0 s:16|16

     a. Without this patch, the cooling state of "fan0" will be kept at 15, even if the temperature is at a lower trip:
       z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15
       ... ...
       z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15

     b. With this patch, the cooling state of "fan0" was continually decreasing to zero according to current trip point:
       z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:15|15
       ... ...
       z:cpu-thermal t:65 t:1 h:16 l:0 c:fan0 s:0|0

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2025-03-15 21:06:45 +08:00 committed by archer
parent 2aab12ff56
commit 0e71a944b9

View file

@ -134,6 +134,10 @@ static unsigned int get_target_state(FAR struct thermal_instance_s *instance,
return validate_state(instance, throttle, cur_state, 1);
}
}
else
{
return validate_state(instance, throttle, cur_state, -1);
}
break;
default: