[COMMON] thermal: core: Added get_zone_by_cool_np API
authorHyeonseong Gil <hs.gil@samsung.com>
Fri, 7 Apr 2017 01:28:58 +0000 (10:28 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:40 +0000 (17:18 +0900)
Resolved migration conflicts from kernel 4.9 to 4.14.

Change-Id: Iae4191873a0482425647e141f548b0d11f5a072e
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/thermal_core.c
include/linux/thermal.h

index 53293494fa9ff33b153947913a7384bcb030b1d0..352ecb7133580b64624263577af52632cf97bc15 100644 (file)
@@ -1424,6 +1424,38 @@ exit:
 }
 EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
 
+struct thermal_zone_device *
+thermal_zone_get_zone_by_cool_np(struct device_node *cool_np)
+{
+       struct thermal_zone_device *pos = NULL, *ref = ERR_PTR(-EINVAL);
+       unsigned int i;
+
+       if (!cool_np)
+               goto exit;
+
+       mutex_lock(&thermal_list_lock);
+       list_for_each_entry(pos, &thermal_tz_list, node) {
+               struct __thermal_zone *data = pos->devdata;
+
+               for (i = 0; i < data->num_tbps; i++) {
+                       struct __thermal_bind_params *tbp = data->tbps + i;
+                       if (tbp->cooling_device == cool_np) {
+                               ref = pos;
+                               mutex_unlock(&thermal_list_lock);
+                               goto exit;
+                       }
+               }
+       }
+       mutex_unlock(&thermal_list_lock);
+
+       /* nothing has been found, thus an error code for it */
+       ref = ERR_PTR(-ENODEV);
+exit:
+       return ref;
+
+}
+EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_cool_np);
+
 #ifdef CONFIG_NET
 static const struct genl_multicast_group thermal_event_mcgrps[] = {
        { .name = THERMAL_GENL_MCAST_GROUP_NAME, },
index edb4c69d8b81280561abe241b8af9ecd97306f8f..3cdd384973496b29ee880ce8195f58bbc35711b7 100644 (file)
@@ -529,6 +529,7 @@ thermal_of_cooling_device_register(struct device_node *np, char *, void *,
                                   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
+struct thermal_zone_device *thermal_zone_get_zone_by_cool_np(struct device_node *cool_np);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
 int thermal_zone_get_slope(struct thermal_zone_device *tz);
 int thermal_zone_get_offset(struct thermal_zone_device *tz);
@@ -589,6 +590,9 @@ static inline void thermal_cooling_device_unregister(
 static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
                const char *name)
 { return ERR_PTR(-ENODEV); }
+static inline struct thermal_zone_device *thermal_zone_get_zone_by_cool_np(
+               struct device_node *cool_np)
+{ return ERR_PTR(-ENODEV); }
 static inline int thermal_zone_get_temp(
                struct thermal_zone_device *tz, int *temp)
 { return -ENODEV; }