Skip to content

Commit 0b28ba2

Browse files
committed
thermal: intel: intel_soc_dts_iosf: Untangle update_trip_temp()
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> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
1 parent 4f16443 commit 0b28ba2

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
6767
}
6868

6969
static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts,
70-
int thres_index, int temp,
71-
enum thermal_trip_type trip_type)
70+
int thres_index, int temp)
7271
{
7372
int status;
7473
u32 temp_out;
@@ -142,8 +141,6 @@ static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts,
142141
if (status)
143142
goto err_restore_te_out;
144143

145-
dts->trip_types[thres_index] = trip_type;
146-
147144
return 0;
148145
err_restore_te_out:
149146
iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE,
@@ -159,6 +156,21 @@ static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts,
159156
return status;
160157
}
161158

159+
static int configure_trip(struct intel_soc_dts_sensor_entry *dts,
160+
int thres_index, enum thermal_trip_type trip_type,
161+
int temp)
162+
{
163+
int ret;
164+
165+
ret = update_trip_temp(dts, thres_index, temp);
166+
if (ret)
167+
return ret;
168+
169+
dts->trip_types[thres_index] = trip_type;
170+
171+
return 0;
172+
}
173+
162174
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
163175
int temp)
164176
{
@@ -170,8 +182,7 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
170182
return -EINVAL;
171183

172184
mutex_lock(&sensors->dts_update_lock);
173-
status = update_trip_temp(dts, trip, temp,
174-
dts->trip_types[trip]);
185+
status = update_trip_temp(dts, trip, temp);
175186
mutex_unlock(&sensors->dts_update_lock);
176187

177188
return status;
@@ -317,7 +328,7 @@ int intel_soc_dts_iosf_add_read_only_critical_trip(
317328

318329
j = find_first_zero_bit(&mask, SOC_MAX_DTS_TRIPS);
319330
if (j < SOC_MAX_DTS_TRIPS)
320-
return update_trip_temp(entry, j, temp, THERMAL_TRIP_CRITICAL);
331+
return configure_trip(entry, j, THERMAL_TRIP_CRITICAL, temp);
321332
}
322333

323334
return -EINVAL;
@@ -395,13 +406,13 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
395406
}
396407

397408
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
398-
ret = update_trip_temp(&sensors->soc_dts[i], 0, 0,
399-
THERMAL_TRIP_PASSIVE);
409+
ret = configure_trip(&sensors->soc_dts[i], 0,
410+
THERMAL_TRIP_PASSIVE, 0);
400411
if (ret)
401412
goto err_remove_zone;
402413

403-
ret = update_trip_temp(&sensors->soc_dts[i], 1, 0,
404-
THERMAL_TRIP_PASSIVE);
414+
ret = configure_trip(&sensors->soc_dts[i], 1,
415+
THERMAL_TRIP_PASSIVE, 0);
405416
if (ret)
406417
goto err_remove_zone;
407418
}
@@ -422,8 +433,8 @@ void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors)
422433
int i;
423434

424435
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
425-
update_trip_temp(&sensors->soc_dts[i], 0, 0, 0);
426-
update_trip_temp(&sensors->soc_dts[i], 1, 0, 0);
436+
configure_trip(&sensors->soc_dts[i], 0, 0, 0);
437+
configure_trip(&sensors->soc_dts[i], 1, 0, 0);
427438
remove_dts_thermal_zone(&sensors->soc_dts[i]);
428439
}
429440
kfree(sensors);

0 commit comments

Comments
 (0)