All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Nguyen <congnt264@gmail.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>, Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-pm@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] thermal/drivers/imx: drop the runtime PM reference on early error returns
Date: Sun, 29 Nov 2026 13:44:12 +0700	[thread overview]
Message-ID: <20261129064412.2874472-1-congnt264@gmail.com> (raw)

imx_get_temp() returns -EAGAIN and imx_set_trip_temp() returns -EINVAL
after taking a runtime PM reference, without dropping it. The usage count
stays raised, so the device can no longer runtime suspend.

Drop the reference before returning on those paths.

Fixes: 4cf2ddf16e17 ("thermal/drivers/imx: Implement runtime PM support")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
 drivers/thermal/imx_thermal.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 1a57aa9dc900..3529b4a4cce1 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -266,8 +266,10 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
 
 	regmap_read(map, soc_data->temp_data, &val);
 
-	if ((val & soc_data->temp_valid_mask) == 0)
+	if ((val & soc_data->temp_valid_mask) == 0) {
+		pm_runtime_put(data->dev);
 		return -EAGAIN;
+	}
 
 	n_meas = (val & soc_data->temp_value_mask)
 		>> soc_data->temp_value_shift;
@@ -342,8 +344,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,
 		return ret;
 
 	/* do not allow passive to be set higher than critical */
-	if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
+	if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) {
+		pm_runtime_put(data->dev);
 		return -EINVAL;
+	}
 
 	imx_set_alarm_temp(data, temp);
 	trips[IMX_TRIP_PASSIVE].temperature = temp;
-- 
2.25.1


             reply	other threads:[~2026-11-29  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  6:44 Cong Nguyen [this message]
2026-11-29  6:47 ` [PATCH] thermal/drivers/imx: drop the runtime PM reference on early error returns sashiko-bot

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=20261129064412.2874472-1-congnt264@gmail.com \
    --to=congnt264@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.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=s.hauer@pengutronix.de \
    /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.