Skip to content

Commit 33fcb59

Browse files
committed
thermal: core: Initialize poll_queue in thermal_zone_device_init()
In preparation for a subsequent change, move the initialization of the poll_queue delayed work from thermal_zone_device_register_with_trips() to thermal_zone_device_init() which is called by the former. However, because thermal_zone_device_init() is also called by thermal_pm_notify(), make the latter call cancel_delayed_work() on poll_queue before invoking the former, so as to allow the work item to be re-initialized safely. Also move thermal_zone_device_check() which needs to be defined before thermal_zone_device_init(), so the latter can pass it to the INIT_DELAYED_WORK() macro. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4e81417 commit 33fcb59

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

drivers/thermal/thermal_core.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,20 @@ static void update_temperature(struct thermal_zone_device *tz)
414414
thermal_genl_sampling_temp(tz->id, temp);
415415
}
416416

417+
static void thermal_zone_device_check(struct work_struct *work)
418+
{
419+
struct thermal_zone_device *tz = container_of(work, struct
420+
thermal_zone_device,
421+
poll_queue.work);
422+
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
423+
}
424+
417425
static void thermal_zone_device_init(struct thermal_zone_device *tz)
418426
{
419427
struct thermal_instance *pos;
428+
429+
INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
430+
420431
tz->temperature = THERMAL_TEMP_INVALID;
421432
tz->prev_low_trip = -INT_MAX;
422433
tz->prev_high_trip = INT_MAX;
@@ -513,14 +524,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
513524
}
514525
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
515526

516-
static void thermal_zone_device_check(struct work_struct *work)
517-
{
518-
struct thermal_zone_device *tz = container_of(work, struct
519-
thermal_zone_device,
520-
poll_queue.work);
521-
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
522-
}
523-
524527
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
525528
void *data)
526529
{
@@ -1376,8 +1379,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
13761379
/* Bind cooling devices for this zone */
13771380
bind_tz(tz);
13781381

1379-
INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
1380-
13811382
thermal_zone_device_init(tz);
13821383
/* Update the new thermal zone and mark it as already updated. */
13831384
if (atomic_cmpxchg(&tz->need_update, 1, 0))
@@ -1560,6 +1561,8 @@ static int thermal_pm_notify(struct notifier_block *nb,
15601561
list_for_each_entry(tz, &thermal_tz_list, node) {
15611562
mutex_lock(&tz->lock);
15621563

1564+
cancel_delayed_work(&tz->poll_queue);
1565+
15631566
tz->suspended = false;
15641567

15651568
thermal_zone_device_init(tz);

0 commit comments

Comments
 (0)