From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: daniel.lezcano@oss.qualcomm.com
Cc: andersson@kernel.org, Amit Kucheria <amitk@kernel.org>,
Thara Gopinath <thara.gopinath@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM MAILING
LIST),
linux-pm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL
DRIVER), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 3/3] thermal/drivers/qcom/tsens: Disable hardware on probe failure
Date: Wed, 21 Oct 2026 10:57:48 +0200 [thread overview]
Message-ID: <20261021085749.3786101-3-daniel.lezcano@oss.qualcomm.com> (raw)
In-Reply-To: <20261021085749.3786101-1-daniel.lezcano@oss.qualcomm.com>
Hardware initialization enables TSENS interrupts before calibration and
thermal zone and IRQ registration have completed. If calibration or
registration fails, probe returns without disabling the hardware. Devres
then releases any registered IRQ handlers, leaving the interrupt source
enabled without a handler.
Factor the hardware shutdown sequence out of the remove callback and
invoke it when calibration or registration fails after successful
initialization. Disable hardware interrupts and call the optional sensor
disable callback before devres releases IRQ handlers and register maps.
Fixes: 634e11d5b450 ("drivers: thermal: tsens: Add interrupt support")
Closes: https://sashiko.dev/#/bug/linux-4b873699-7a0d-46e9-b768-169916c70d1d
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Cc: Amit Kucheria <amitk@kernel.org>
---
drivers/thermal/qcom/tsens.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 9134637a3458..57d71159bd4b 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1374,6 +1374,13 @@ static int tsens_register(struct tsens_priv *priv)
return ret;
}
+static void tsens_disable(struct tsens_priv *priv)
+{
+ tsens_disable_irq(priv);
+ if (priv->ops->disable)
+ priv->ops->disable(priv);
+}
+
static int tsens_probe_common(struct platform_device *pdev)
{
int ret, i;
@@ -1450,15 +1457,22 @@ static int tsens_probe_common(struct platform_device *pdev)
if (priv->ops->calibrate) {
ret = priv->ops->calibrate(priv);
- if (ret < 0)
- return dev_err_probe(dev, ret, "%s: calibration failed\n",
- __func__);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "%s: calibration failed\n", __func__);
+ goto err_disable;
+ }
}
ret = tsens_register(priv);
- if (!ret)
- tsens_debug_init(pdev);
+ if (ret)
+ goto err_disable;
+
+ tsens_debug_init(pdev);
+ return 0;
+err_disable:
+ /* Stop hardware events before devres releases IRQs and register maps. */
+ tsens_disable(priv);
return ret;
}
@@ -1502,9 +1516,7 @@ static void tsens_remove(struct platform_device *pdev)
struct tsens_priv *priv = platform_get_drvdata(pdev);
debugfs_remove_recursive(priv->debug_root);
- tsens_disable_irq(priv);
- if (priv->ops->disable)
- priv->ops->disable(priv);
+ tsens_disable(priv);
}
static struct platform_driver tsens_driver = {
--
2.43.0
next prev parent reply other threads:[~2026-10-21 8:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 8:57 [PATCH 1/3] thermal/drivers/qcom/tsens: Release parent resources " Daniel Lezcano
2026-10-21 8:57 ` [PATCH 2/3] thermal/drivers/qcom/tsens: Validate the sensor count before initialization Daniel Lezcano
2026-10-21 8:57 ` Daniel Lezcano [this message]
2026-10-21 10:27 ` [PATCH 3/3] thermal/drivers/qcom/tsens: Disable hardware on probe failure Konrad Dybcio
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=20261021085749.3786101-3-daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=amitk@kernel.org \
--cc=andersson@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=thara.gopinath@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®