linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 1/4] thermal/core: Emit a warning if the thermal zone is updated without ops
@ 2020-12-09 15:34 Daniel Lezcano
  2020-12-09 15:34 ` [PATCH RFC 2/4] thermal/core: Add critical and hot ops Daniel Lezcano
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Daniel Lezcano @ 2020-12-09 15:34 UTC (permalink / raw)
  To: daniel.lezcano, rui.zhang
  Cc: linux-kernel, linux-pm, lukasz.luba, srinivas.pandruvada, kai.heng.feng

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 <thara.gopinath@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/thermal_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index dee40ff41177..afc02e7d1045 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -548,7 +548,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", __FUNCTION__))
 		return;
 
 	update_temperature(tz);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-10  9:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 15:34 [PATCH RFC 1/4] thermal/core: Emit a warning if the thermal zone is updated without ops Daniel Lezcano
2020-12-09 15:34 ` [PATCH RFC 2/4] thermal/core: Add critical and hot ops Daniel Lezcano
2020-12-10  9:28   ` Kai-Heng Feng
2020-12-09 15:34 ` [PATCH RFC 3/4] thermal/drivers/acpi: Use hot and critical ops Daniel Lezcano
2020-12-09 15:34 ` [PATCH RFC 4/4] thermal/core: Remove notify ops Daniel Lezcano
2020-12-09 15:53 ` [PATCH RFC 1/4] thermal/core: Emit a warning if the thermal zone is updated without ops Lukasz Luba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).