Commit 33fcb595 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 4e814173
...@@ -414,9 +414,20 @@ static void update_temperature(struct thermal_zone_device *tz) ...@@ -414,9 +414,20 @@ static void update_temperature(struct thermal_zone_device *tz)
thermal_genl_sampling_temp(tz->id, temp); thermal_genl_sampling_temp(tz->id, temp);
} }
static void thermal_zone_device_check(struct work_struct *work)
{
struct thermal_zone_device *tz = container_of(work, struct
thermal_zone_device,
poll_queue.work);
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
}
static void thermal_zone_device_init(struct thermal_zone_device *tz) static void thermal_zone_device_init(struct thermal_zone_device *tz)
{ {
struct thermal_instance *pos; struct thermal_instance *pos;
INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
tz->temperature = THERMAL_TEMP_INVALID; tz->temperature = THERMAL_TEMP_INVALID;
tz->prev_low_trip = -INT_MAX; tz->prev_low_trip = -INT_MAX;
tz->prev_high_trip = INT_MAX; tz->prev_high_trip = INT_MAX;
...@@ -513,14 +524,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, ...@@ -513,14 +524,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
} }
EXPORT_SYMBOL_GPL(thermal_zone_device_update); EXPORT_SYMBOL_GPL(thermal_zone_device_update);
static void thermal_zone_device_check(struct work_struct *work)
{
struct thermal_zone_device *tz = container_of(work, struct
thermal_zone_device,
poll_queue.work);
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
}
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
void *data) void *data)
{ {
...@@ -1376,8 +1379,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1376,8 +1379,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
/* Bind cooling devices for this zone */ /* Bind cooling devices for this zone */
bind_tz(tz); bind_tz(tz);
INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
thermal_zone_device_init(tz); thermal_zone_device_init(tz);
/* Update the new thermal zone and mark it as already updated. */ /* Update the new thermal zone and mark it as already updated. */
if (atomic_cmpxchg(&tz->need_update, 1, 0)) if (atomic_cmpxchg(&tz->need_update, 1, 0))
...@@ -1560,6 +1561,8 @@ static int thermal_pm_notify(struct notifier_block *nb, ...@@ -1560,6 +1561,8 @@ static int thermal_pm_notify(struct notifier_block *nb,
list_for_each_entry(tz, &thermal_tz_list, node) { list_for_each_entry(tz, &thermal_tz_list, node) {
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
cancel_delayed_work(&tz->poll_queue);
tz->suspended = false; tz->suspended = false;
thermal_zone_device_init(tz); thermal_zone_device_init(tz);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment