Skip to content

Commit bdc22c8

Browse files
committed
thermal: trip: Send trip change notifications on all trip updates
The _store callbacks of the trip point temperature and hysteresis sysfs attributes invoke thermal_notify_tz_trip_change() to send a notification regarding the trip point change, but when trip points are updated by the platform firmware, trip point change notifications are not sent. To make the behavior after a trip point change more consistent, modify all of the 3 places where trip point temperature is updated to use a new function called thermal_zone_set_trip_temp() for this purpose and make that function call thermal_notify_tz_trip_change(). Note that trip point hysteresis can only be updated via sysfs and trip_point_hyst_store() calls thermal_notify_tz_trip_change() already, so this code path need not be changed. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 183b641 commit bdc22c8

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

drivers/acpi/thermal.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data)
297297
struct acpi_thermal_trip *acpi_trip = trip->priv;
298298
struct adjust_trip_data *atd = data;
299299
struct acpi_thermal *tz = atd->tz;
300+
int temp;
300301

301302
if (!acpi_trip || !acpi_thermal_trip_valid(acpi_trip))
302303
return 0;
@@ -307,9 +308,11 @@ static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data)
307308
acpi_thermal_update_trip_devices(tz, trip);
308309

309310
if (acpi_thermal_trip_valid(acpi_trip))
310-
trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk);
311+
temp = acpi_thermal_temp(tz, acpi_trip->temp_dk);
311312
else
312-
trip->temperature = THERMAL_TEMP_INVALID;
313+
temp = THERMAL_TEMP_INVALID;
314+
315+
thermal_zone_set_trip_temp(tz->thermal_zone, trip, temp);
313316

314317
return 0;
315318
}

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
225225

226226
static int int340x_update_one_trip(struct thermal_trip *trip, void *arg)
227227
{
228-
struct acpi_device *zone_adev = arg;
228+
struct int34x_thermal_zone *int34x_zone = arg;
229+
struct acpi_device *zone_adev = int34x_zone->adev;
229230
int temp, err;
230231

231232
switch (trip->type) {
@@ -249,14 +250,15 @@ static int int340x_update_one_trip(struct thermal_trip *trip, void *arg)
249250
if (err)
250251
temp = THERMAL_TEMP_INVALID;
251252

252-
trip->temperature = temp;
253+
thermal_zone_set_trip_temp(int34x_zone->zone, trip, temp);
254+
253255
return 0;
254256
}
255257

256258
void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
257259
{
258260
thermal_zone_for_each_trip(int34x_zone->zone, int340x_update_one_trip,
259-
int34x_zone->adev);
261+
int34x_zone);
260262
}
261263
EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);
262264

drivers/thermal/thermal_sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
129129
goto unlock;
130130
}
131131

132-
trip->temperature = temp;
132+
thermal_zone_set_trip_temp(tz, trip, temp);
133133

134-
thermal_zone_trip_updated(tz, trip);
134+
__thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED);
135135
}
136136

137137
unlock:

drivers/thermal/thermal_trip.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ int thermal_zone_trip_id(struct thermal_zone_device *tz,
152152
*/
153153
return trip - tz->trips;
154154
}
155-
156155
void thermal_zone_trip_updated(struct thermal_zone_device *tz,
157156
const struct thermal_trip *trip)
158157
{
@@ -161,3 +160,16 @@ void thermal_zone_trip_updated(struct thermal_zone_device *tz,
161160
trip->hysteresis);
162161
__thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED);
163162
}
163+
164+
void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
165+
struct thermal_trip *trip, int temp)
166+
{
167+
if (trip->temperature == temp)
168+
return;
169+
170+
trip->temperature = temp;
171+
thermal_notify_tz_trip_change(tz->id, thermal_zone_trip_id(tz, trip),
172+
trip->type, trip->temperature,
173+
trip->hysteresis);
174+
}
175+
EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);

include/linux/thermal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
291291
int (*cb)(struct thermal_trip *, void *),
292292
void *data);
293293
int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
294+
void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
295+
struct thermal_trip *trip, int temp);
294296

295297
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
296298

0 commit comments

Comments
 (0)