[COMMON] thermal: samsung: Replace to get cdev data
authorHyeonseong Gil <hs.gil@samsung.com>
Fri, 24 Mar 2017 01:59:09 +0000 (10:59 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:37 +0000 (17:18 +0900)
Change-Id: I5f706db307e107d6ea129a6864396f75d480efa5
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/samsung/exynos_tmu.c

index 94e6bccbe3e1a91275e103f8e3e4d1a11cdbd4e7..8ec8450f695ecc8bc12b68f94069cf53018626a8 100644 (file)
@@ -928,7 +928,9 @@ static void exynos78XX_tmu_control(struct platform_device *pdev, bool on)
 static int exynos_get_temp(void *p, int *temp)
 {
        struct exynos_tmu_data *data = p;
-       struct thermal_cooling_device *cdev;
+       struct thermal_cooling_device *cdev = NULL;
+       struct thermal_zone_device *tz;
+       struct thermal_instance *instance;
 #ifdef CONFIG_EXYNOS_MCINFO
        unsigned int mcinfo_count;
        unsigned int mcinfo_result[4] = {0, 0, 0, 0};
@@ -949,7 +951,14 @@ static int exynos_get_temp(void *p, int *temp)
 
        mutex_unlock(&data->lock);
 
-       cdev = data->cool_dev;
+       tz = data->tzd;
+
+       list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+               if (instance->cdev) {
+                       cdev = instance->cdev;
+                       break;
+               }
+       }
 
        if (!cdev)
                return 0;
@@ -1192,14 +1201,22 @@ static int exynos_pm_notifier(struct notifier_block *notifier,
                        unsigned long event, void *v)
 {
        struct exynos_tmu_data *devnode;
-       struct thermal_cooling_device *cdev;
+       struct thermal_cooling_device *cdev = NULL;
+       struct thermal_zone_device *tz;
+       struct thermal_instance *instance;
 
        switch (event) {
        case PM_SUSPEND_PREPARE:
                mutex_lock(&thermal_suspend_lock);
                suspended = true;
                list_for_each_entry(devnode, &dtm_dev_list, node) {
-                       cdev = devnode->cool_dev;
+                       tz = devnode->tzd;
+                       list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+                               if (instance->cdev) {
+                                       cdev = instance->cdev;
+                                       break;
+                               }
+                       }
 
                        if (cdev && cdev->ops->set_cur_temp && devnode->id != 1)
                                cdev->ops->set_cur_temp(cdev, suspended, 0);
@@ -1211,6 +1228,13 @@ static int exynos_pm_notifier(struct notifier_block *notifier,
                suspended = false;
                list_for_each_entry(devnode, &dtm_dev_list, node) {
                        cdev = devnode->cool_dev;
+                       tz = devnode->tzd;
+                       list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+                               if (instance->cdev) {
+                                       cdev = instance->cdev;
+                                       break;
+                               }
+                       }
 
                        if (cdev && cdev->ops->set_cur_temp && devnode->id != 1)
                                cdev->ops->set_cur_temp(cdev, suspended, devnode->tzd->temperature / 1000);