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 7/7] thermal: intel: intel_soc_dts_iosf: Use struct thermal_trip
Date: Thu, 10 Aug 2023 21:17:36 +0200 [thread overview]
Message-ID: <2249203.iZASKD2KPV@kreacher> (raw)
In-Reply-To: <5713357.DvuYhMxLoT@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Because the number of trip points in each thermal zone and their
types are known to intel_soc_dts_iosf_init() prior to the registration
of the thermal zones, make it create an array of struct thermal_trip
entries in each struct intel_soc_dts_sensor_entry object and make
add_dts_thermal_zone() use thermal_zone_device_register_with_trips()
for thermal zone registration and pass that array as its second
argument.
Drop the sys_get_trip_temp() and sys_get_trip_type() callback
functions along with the respective callback pointers in
tzone_ops, because they are not necessary any more.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/thermal/intel/intel_soc_dts_iosf.c | 51 +++--------------------------
drivers/thermal/intel/intel_soc_dts_iosf.h | 2 -
2 files changed, 8 insertions(+), 45 deletions(-)
Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.h
===================================================================
--- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.h
+++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.h
@@ -29,7 +29,7 @@ struct intel_soc_dts_sensor_entry {
int id;
u32 store_status;
u32 trip_mask;
- enum thermal_trip_type trip_types[SOC_MAX_DTS_TRIPS];
+ struct thermal_trip trips[SOC_MAX_DTS_TRIPS];
struct thermal_zone_device *tzone;
struct intel_soc_dts_sensors *sensors;
};
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
@@ -40,32 +40,6 @@
/* Mask for two trips in status bits */
#define SOC_DTS_TRIP_MASK 0x03
-static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
- int *temp)
-{
- int status;
- u32 out;
- struct intel_soc_dts_sensor_entry *dts;
- struct intel_soc_dts_sensors *sensors;
-
- dts = thermal_zone_device_priv(tzd);
- sensors = dts->sensors;
- mutex_lock(&sensors->dts_update_lock);
- status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
- SOC_DTS_OFFSET_PTPS, &out);
- mutex_unlock(&sensors->dts_update_lock);
- if (status)
- return status;
-
- out = (out >> (trip * 8)) & SOC_DTS_TJMAX_ENCODING;
- if (!out)
- *temp = 0;
- else
- *temp = sensors->tj_max - out * 1000;
-
- return 0;
-}
-
static int update_trip_temp(struct intel_soc_dts_sensors *sensors,
int thres_index, int temp)
{
@@ -165,7 +139,8 @@ static int configure_trip(struct intel_s
if (ret)
return ret;
- dts->trip_types[thres_index] = trip_type;
+ dts->trips[thres_index].temperature = temp;
+ dts->trips[thres_index].type = trip_type;
return 0;
}
@@ -187,16 +162,6 @@ static int sys_set_trip_temp(struct ther
return status;
}
-static int sys_get_trip_type(struct thermal_zone_device *tzd,
- int trip, enum thermal_trip_type *type)
-{
- struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
-
- *type = dts->trip_types[trip];
-
- return 0;
-}
-
static int sys_get_curr_temp(struct thermal_zone_device *tzd,
int *temp)
{
@@ -221,8 +186,6 @@ static int sys_get_curr_temp(struct ther
static struct thermal_zone_device_ops tzone_ops = {
.get_temp = sys_get_curr_temp,
- .get_trip_temp = sys_get_trip_temp,
- .get_trip_type = sys_get_trip_type,
.set_trip_temp = sys_set_trip_temp,
};
@@ -293,11 +256,11 @@ static int add_dts_thermal_zone(int id,
}
dts->trip_mask = trip_mask;
snprintf(name, sizeof(name), "soc_dts%d", id);
- dts->tzone = thermal_zone_device_register(name,
- SOC_MAX_DTS_TRIPS,
- trip_mask,
- dts, &tzone_ops,
- NULL, 0, 0);
+ dts->tzone = thermal_zone_device_register_with_trips(name, dts->trips,
+ SOC_MAX_DTS_TRIPS,
+ trip_mask,
+ dts, &tzone_ops,
+ NULL, 0, 0);
if (IS_ERR(dts->tzone)) {
ret = PTR_ERR(dts->tzone);
goto err_ret;
next prev parent reply other threads:[~2023-08-10 19:17 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 ` [PATCH v1 2/7] thermal: intel: intel_soc_dts_iosf: Untangle update_trip_temp() Rafael J. Wysocki
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 ` Rafael J. Wysocki [this message]
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=2249203.iZASKD2KPV@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