From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Zhang Rui <rui.zhang@intel.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH v1 2/7] thermal: intel: intel_soc_dts_iosf: Untangle update_trip_temp()
Date: Thu, 10 Aug 2023 21:11:26 +0200 [thread overview]
Message-ID: <2306583.ElGaqSPkdT@kreacher> (raw)
In-Reply-To: <5713357.DvuYhMxLoT@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Function update_trip_temp() is currently used for the initialization
of trip points as well as for changing trip point temperatures in
sys_set_trip_temp().
This is quite confusing and passing the value of dts->trip_types[trip]
to it so that it can store that value in the same memory location is
not particularly useful, because it only is necessary to set the
trip point type once, at the initialization time.
For this reason, drop the last argument from update_trip_temp() and
introduce configure_trip() calling the former internally for the
initial configuration of trip points.
Modify the majority of update_trip_temp() callers to use
configure_trip() instead of it.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/thermal/intel/intel_soc_dts_iosf.c | 37 ++++++++++++++++++-----------
1 file changed, 24 insertions(+), 13 deletions(-)
Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c
+++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c
@@ -67,8 +67,7 @@ static int sys_get_trip_temp(struct ther
}
static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts,
- int thres_index, int temp,
- enum thermal_trip_type trip_type)
+ int thres_index, int temp)
{
int status;
u32 temp_out;
@@ -142,8 +141,6 @@ static int update_trip_temp(struct intel
if (status)
goto err_restore_te_out;
- dts->trip_types[thres_index] = trip_type;
-
return 0;
err_restore_te_out:
iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE,
@@ -159,6 +156,21 @@ err_restore_ptps:
return status;
}
+static int configure_trip(struct intel_soc_dts_sensor_entry *dts,
+ int thres_index, enum thermal_trip_type trip_type,
+ int temp)
+{
+ int ret;
+
+ ret = update_trip_temp(dts, thres_index, temp);
+ if (ret)
+ return ret;
+
+ dts->trip_types[thres_index] = trip_type;
+
+ return 0;
+}
+
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
int temp)
{
@@ -170,8 +182,7 @@ static int sys_set_trip_temp(struct ther
return -EINVAL;
mutex_lock(&sensors->dts_update_lock);
- status = update_trip_temp(dts, trip, temp,
- dts->trip_types[trip]);
+ status = update_trip_temp(dts, trip, temp);
mutex_unlock(&sensors->dts_update_lock);
return status;
@@ -317,7 +328,7 @@ int intel_soc_dts_iosf_add_read_only_cri
j = find_first_zero_bit(&mask, SOC_MAX_DTS_TRIPS);
if (j < SOC_MAX_DTS_TRIPS)
- return update_trip_temp(entry, j, temp, THERMAL_TRIP_CRITICAL);
+ return configure_trip(entry, j, THERMAL_TRIP_CRITICAL, temp);
}
return -EINVAL;
@@ -395,13 +406,13 @@ struct intel_soc_dts_sensors *intel_soc_
}
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
- ret = update_trip_temp(&sensors->soc_dts[i], 0, 0,
- THERMAL_TRIP_PASSIVE);
+ ret = configure_trip(&sensors->soc_dts[i], 0,
+ THERMAL_TRIP_PASSIVE, 0);
if (ret)
goto err_remove_zone;
- ret = update_trip_temp(&sensors->soc_dts[i], 1, 0,
- THERMAL_TRIP_PASSIVE);
+ ret = configure_trip(&sensors->soc_dts[i], 1,
+ THERMAL_TRIP_PASSIVE, 0);
if (ret)
goto err_remove_zone;
}
@@ -422,8 +433,8 @@ void intel_soc_dts_iosf_exit(struct inte
int i;
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
- update_trip_temp(&sensors->soc_dts[i], 0, 0, 0);
- update_trip_temp(&sensors->soc_dts[i], 1, 0, 0);
+ configure_trip(&sensors->soc_dts[i], 0, 0, 0);
+ configure_trip(&sensors->soc_dts[i], 1, 0, 0);
remove_dts_thermal_zone(&sensors->soc_dts[i]);
}
kfree(sensors);
next prev parent reply other threads:[~2023-08-10 19:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 19:08 [PATCH v1 0/7] thermal: intel: intel_soc_dts_iosf: Cleanups, fixes and usage of generic trips Rafael J. Wysocki
2023-08-10 19:09 ` [PATCH v1 1/7] thermal: intel: intel_soc_dts_iosf: Always assume notification support Rafael J. Wysocki
2023-08-10 19:11 ` Rafael J. Wysocki [this message]
2023-08-10 19:12 ` [PATCH v1 3/7] thermal: intel: intel_soc_dts_iosf: Pass sensors to update_trip_temp() Rafael J. Wysocki
2023-08-10 19:13 ` [PATCH v1 4/7] thermal: intel: intel_soc_dts_iosf: Change initialization ordering Rafael J. Wysocki
2023-08-10 19:14 ` [PATCH v1 5/7] thermal: intel: intel_soc_dts_iosf: Add helper for resetting trip points Rafael J. Wysocki
2023-08-10 19:16 ` [PATCH v1 6/7] thermal: intel: intel_soc_dts_iosf: Rework critical trip setup Rafael J. Wysocki
2023-08-10 19:17 ` [PATCH v1 7/7] thermal: intel: intel_soc_dts_iosf: Use struct thermal_trip Rafael J. Wysocki
2023-08-11 0:00 ` [PATCH v1 0/7] thermal: intel: intel_soc_dts_iosf: Cleanups, fixes and usage of generic trips srinivas pandruvada
2023-08-11 7:59 ` 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=2306583.ElGaqSPkdT@kreacher \
--to=rjw@rjwysocki.net \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
--cc=srinivas.pandruvada@linux.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