mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: rafael.j.wysocki@intel.com
Cc: daniel.lezcano@linaro.or, srinivas.pandruvada@intel.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: [PATCH] thermal: intel: intel_soc_dts_iosf: Fix thermal_zone removal
Date: Fri, 11 Aug 2023 16:45:23 +0800	[thread overview]
Message-ID: <20230811084523.1689671-1-rui.zhang@intel.com> (raw)

All of the existing callers of remove_dts_thermal_zone() pass a valid
pointer as the argument, so checking for the NULL pointer is redundant.

Plus, when calling remove_dts_thermal_zone() from
intel_soc_dts_iosf_init(), it is possible that
1. dts->tzone is an error pointer, when the sensor fails to be
   registered as a valid thermal zone
2. dts->tzone is unregistered in add_dts_thermal_zone(), when some
   failure occurs after thermal zone registered
In both cases, there is no need to unregister dts->tzone in
remove_dts_thermal_zone().

Clear dst->tzone when add_dts_thermal_zone() fails. And do thermal zone
removal in remove_dts_thermal_zone() only when dts->tzone is set.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/intel/intel_soc_dts_iosf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c
index 7a66d0f077b0..c5203ba8f0b9 100644
--- a/drivers/thermal/intel/intel_soc_dts_iosf.c
+++ b/drivers/thermal/intel/intel_soc_dts_iosf.c
@@ -212,7 +212,7 @@ static int soc_dts_enable(int id)
 
 static void remove_dts_thermal_zone(struct intel_soc_dts_sensor_entry *dts)
 {
-	if (dts) {
+	if (dts->tzone) {
 		iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE,
 			       SOC_DTS_OFFSET_ENABLE, dts->store_status);
 		thermal_zone_device_unregister(dts->tzone);
@@ -277,6 +277,7 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
 err_enable:
 	thermal_zone_device_unregister(dts->tzone);
 err_ret:
+	dts->tzone = NULL;
 	return ret;
 }
 
-- 
2.34.1


             reply	other threads:[~2023-08-11  8:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  8:45 Zhang Rui [this message]
2023-08-11 16:55 ` Rafael J. Wysocki
2023-08-13  3:11   ` Zhang, Rui

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=20230811084523.1689671-1-rui.zhang@intel.com \
    --to=rui.zhang@intel.com \
    --cc=daniel.lezcano@linaro.or \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@intel.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®