[COMMON] thermal: delay cpu hotplug until cdev is initialized
authorEunseok Choi <es10.choi@samsung.com>
Thu, 14 Dec 2017 08:58:48 +0000 (17:58 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:22:20 +0000 (17:22 +0900)
Change-Id: I46e252cde6c2fbaa09acffc1352d6fae4d1496fd
Signed-off-by: Eunseok Choi <es10.choi@samsung.com>
drivers/thermal/thermal_core.c
include/linux/thermal.h

index c60989baedc8aa67c6e3dd9efea0c55df6d9745f..1c38e41d13748746f50612f87d60b3795a360dd1 100644 (file)
@@ -497,7 +497,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
                        handle_thermal_trip(tz, count);
 
                if (event != THERMAL_DEVICE_POWER_CAPABILITY_CHANGED) {
-                       if (tz->ops->throttle_hotplug)
+                       if (tz->ops->throttle_hotplug && tz->cdev_bound)
                                tz->ops->throttle_hotplug(tz);
                }
        }
@@ -1010,9 +1010,11 @@ __thermal_cooling_device_register(struct device_node *np,
 
        mutex_lock(&thermal_list_lock);
        list_for_each_entry(pos, &thermal_tz_list, node)
-               if (atomic_cmpxchg(&pos->need_update, 1, 0))
+               if (atomic_cmpxchg(&pos->need_update, 1, 0)) {
+                       pos->cdev_bound = true;
                        thermal_zone_device_update(pos,
                                                   THERMAL_EVENT_UNSPECIFIED);
+               }
        mutex_unlock(&thermal_list_lock);
 
        return cdev;
index a6fc833258f6ffe9947f911e0a21ef967121e90e..c82bd1e4860f853dc0fbe8f470450af37e198106 100644 (file)
@@ -207,6 +207,7 @@ struct thermal_attr {
  * @node:      node in thermal_tz_list (in thermal_core.c)
  * @poll_queue:        delayed work for polling
  * @notify_event: Last notification event
+ * @cdev_bound: cooling device bind done
  */
 struct thermal_zone_device {
        int id;
@@ -239,6 +240,7 @@ struct thermal_zone_device {
        struct list_head node;
        struct delayed_work poll_queue;
        enum thermal_notify_event notify_event;
+       bool cdev_bound;
 };
 
 /**