From: Hyeonseong Gil Date: Fri, 7 Apr 2017 01:28:58 +0000 (+0900) Subject: [COMMON] thermal: core: Added get_zone_by_cool_np API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3e36d67e466c51829e0bea76bf48b9ac8470f6ec;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] thermal: core: Added get_zone_by_cool_np API Resolved migration conflicts from kernel 4.9 to 4.14. Change-Id: Iae4191873a0482425647e141f548b0d11f5a072e Signed-off-by: Hyeonseong Gil --- diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 53293494fa9f..352ecb713358 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -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, }, diff --git a/include/linux/thermal.h b/include/linux/thermal.h index edb4c69d8b81..3cdd38497349 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -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; }