Skip to content

Commit 4effd28

Browse files
committed
thermal: intel: intel_soc_dts_iosf: Use struct thermal_trip
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 <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]>
1 parent 02a49aa commit 4effd28

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,6 @@
4040
/* Mask for two trips in status bits */
4141
#define SOC_DTS_TRIP_MASK 0x03
4242

43-
static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
44-
int *temp)
45-
{
46-
int status;
47-
u32 out;
48-
struct intel_soc_dts_sensor_entry *dts;
49-
struct intel_soc_dts_sensors *sensors;
50-
51-
dts = thermal_zone_device_priv(tzd);
52-
sensors = dts->sensors;
53-
mutex_lock(&sensors->dts_update_lock);
54-
status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
55-
SOC_DTS_OFFSET_PTPS, &out);
56-
mutex_unlock(&sensors->dts_update_lock);
57-
if (status)
58-
return status;
59-
60-
out = (out >> (trip * 8)) & SOC_DTS_TJMAX_ENCODING;
61-
if (!out)
62-
*temp = 0;
63-
else
64-
*temp = sensors->tj_max - out * 1000;
65-
66-
return 0;
67-
}
68-
6943
static int update_trip_temp(struct intel_soc_dts_sensors *sensors,
7044
int thres_index, int temp)
7145
{
@@ -165,7 +139,8 @@ static int configure_trip(struct intel_soc_dts_sensor_entry *dts,
165139
if (ret)
166140
return ret;
167141

168-
dts->trip_types[thres_index] = trip_type;
142+
dts->trips[thres_index].temperature = temp;
143+
dts->trips[thres_index].type = trip_type;
169144

170145
return 0;
171146
}
@@ -187,16 +162,6 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
187162
return status;
188163
}
189164

190-
static int sys_get_trip_type(struct thermal_zone_device *tzd,
191-
int trip, enum thermal_trip_type *type)
192-
{
193-
struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
194-
195-
*type = dts->trip_types[trip];
196-
197-
return 0;
198-
}
199-
200165
static int sys_get_curr_temp(struct thermal_zone_device *tzd,
201166
int *temp)
202167
{
@@ -221,8 +186,6 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd,
221186

222187
static struct thermal_zone_device_ops tzone_ops = {
223188
.get_temp = sys_get_curr_temp,
224-
.get_trip_temp = sys_get_trip_temp,
225-
.get_trip_type = sys_get_trip_type,
226189
.set_trip_temp = sys_set_trip_temp,
227190
};
228191

@@ -293,11 +256,11 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
293256
}
294257
dts->trip_mask = trip_mask;
295258
snprintf(name, sizeof(name), "soc_dts%d", id);
296-
dts->tzone = thermal_zone_device_register(name,
297-
SOC_MAX_DTS_TRIPS,
298-
trip_mask,
299-
dts, &tzone_ops,
300-
NULL, 0, 0);
259+
dts->tzone = thermal_zone_device_register_with_trips(name, dts->trips,
260+
SOC_MAX_DTS_TRIPS,
261+
trip_mask,
262+
dts, &tzone_ops,
263+
NULL, 0, 0);
301264
if (IS_ERR(dts->tzone)) {
302265
ret = PTR_ERR(dts->tzone);
303266
goto err_ret;

drivers/thermal/intel/intel_soc_dts_iosf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct intel_soc_dts_sensor_entry {
2929
int id;
3030
u32 store_status;
3131
u32 trip_mask;
32-
enum thermal_trip_type trip_types[SOC_MAX_DTS_TRIPS];
32+
struct thermal_trip trips[SOC_MAX_DTS_TRIPS];
3333
struct thermal_zone_device *tzone;
3434
struct intel_soc_dts_sensors *sensors;
3535
};

0 commit comments

Comments
 (0)