Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 3669716

Browse files
committed
thermal: core: Add sanity checks for polling_delay and passive_delay
If polling_delay is nonzero and passive_delay is greater than polling_delay, the thermal zone temperature will be updated less often when tz->passive is nonzero, which is not as expected. Make the thermal zone registration fail with -EINVAL in that case as this is a clear thermal zone configuration mistake. If polling_delay is nonzero and passive_delay is 0, which is regarded as a valid thermal zone configuration, the thermal zone will use polling except when tz->passive is nonzero. However, the expected behavior in that case is to continue temperature polling with the same delay value regardless of tz->passive, so set passive_delay to the polling_delay value then. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://patch.msgid.link/5802156.DvuYhMxLoT@rjwysocki.net
1 parent 5b674ba commit 3669716

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/thermal/thermal_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,14 @@ thermal_zone_device_register_with_trips(const char *type,
13901390
if (num_trips > 0 && !trips)
13911391
return ERR_PTR(-EINVAL);
13921392

1393+
if (polling_delay) {
1394+
if (passive_delay > polling_delay)
1395+
return ERR_PTR(-EINVAL);
1396+
1397+
if (!passive_delay)
1398+
passive_delay = polling_delay;
1399+
}
1400+
13931401
if (!thermal_class)
13941402
return ERR_PTR(-ENODEV);
13951403

0 commit comments

Comments
 (0)