All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rui.zhang@intel.com
Cc: kai.heng.feng@canonical.com, lukasz.luba@arm.com,
	srinivas.pandruvada@linux.intel.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Thara Gopinath <thara.gopinath@linaro.org>,
	Amit Kucheria <amitk@kernel.org>
Subject: [PATCH 1/5] thermal/core: Emit a warning if the thermal zone is updated without ops
Date: Thu, 10 Dec 2020 13:15:10 +0100	[thread overview]
Message-ID: <20201210121514.25760-1-daniel.lezcano@linaro.org> (raw)

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>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
---
 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..e6771e5aeedb 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", __func__))
 		return;
 
 	update_temperature(tz);
-- 
2.17.1


             reply	other threads:[~2020-12-10 12:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 12:15 Daniel Lezcano [this message]
2020-12-10 12:15 ` [PATCH 2/5] thermal/core: Add critical and hot ops Daniel Lezcano
2020-12-10 12:44   ` Lukasz Luba
2020-12-10 13:37     ` Daniel Lezcano
2020-12-10 13:51       ` Lukasz Luba
2020-12-14 14:40   ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2020-12-10 12:15 ` [PATCH 3/5] thermal/drivers/acpi: Use hot and critical ops Daniel Lezcano
2020-12-17  6:28   ` Daniel Lezcano
2020-12-17 11:38     ` Srinivas Pandruvada
2020-12-17 13:10       ` Daniel Lezcano
2021-01-19 21:27   ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2020-12-10 12:15 ` [PATCH 4/5] thermal/drivers/rcar: Remove notification usage Daniel Lezcano
2020-12-10 16:10   ` Niklas Söderlund
2020-12-15 18:17   ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2020-12-10 12:15 ` [PATCH 5/5] thermal/core: Remove notify ops Daniel Lezcano
2020-12-10 14:37   ` Lukasz Luba
2021-01-19 21:27   ` [thermal: thermal/next] " thermal-bot for Daniel Lezcano
2020-12-14 14:40 ` [thermal: thermal/next] thermal/core: Emit a warning if the thermal zone is updated without ops thermal-bot for Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201210121514.25760-1-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=amitk@kernel.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=thara.gopinath@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.