]> Git Repo - linux.git/commitdiff
thermal/core: Emit a warning if the thermal zone is updated without ops
authorDaniel Lezcano <[email protected]>
Thu, 10 Dec 2020 12:15:10 +0000 (13:15 +0100)
committerDaniel Lezcano <[email protected]>
Fri, 11 Dec 2020 13:11:13 +0000 (14:11 +0100)
The actual code is silently ignoring a thermal zone update when a
driver is requesting it without a get_temp ops set.

That looks not correct, as the caller should not have called this
function if the thermal zone is unable to read the temperature.

That makes the code less robust as the check won't detect the driver
is inconsistently using the thermal API and that does not help to
improve the framework as these circumvolutions hide the problem at the
source.

In order to detect the situation when it happens, let's add a warning
when the update is requested without the get_temp() ops set.

Any warning emitted will have to be fixed at the source of the
problem: the caller must not call thermal_zone_device_update if there
is not get_temp callback set.

Cc: Thara Gopinath <[email protected]>
Cc: Amit Kucheria <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Daniel Lezcano <[email protected]>
Reviewed-by: Lukasz Luba <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
drivers/thermal/thermal_core.c

index 90e38cc199f402368b7a33497c4aadef9c1cf905..64de09861c05fc5ff59f8fb30ee861c411c10d8e 100644 (file)
@@ -553,7 +553,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
        if (atomic_read(&in_suspend))
                return;
 
-       if (!tz->ops->get_temp)
+       if (WARN_ONCE(!tz->ops->get_temp, "'%s' must not be called without "
+                     "'get_temp' ops set\n", __func__))
                return;
 
        update_temperature(tz);
This page took 0.055636 seconds and 4 git commands to generate.