Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0f90379 authored by George Lee's avatar George Lee Committed by Hridya Valsaraju
Browse files

ANDROID: GKI: Thermal: thermal_zone_get_cdev_by_name added



thermal_zone_get_cdev_by_name added to thermal_core for cooling device
querying by name.

Bug: 128625129
Bug: 143740346
Bug: 149945768
Test: build
Change-Id: I3253e61800f8514769d1efc33111dec1e9000e26
Signed-off-by: default avatarGeorge Lee <geolee@google.com>
(cherry picked from commit e1a515b24088b0051506fa7d54c5b9d6e6b870b0)
Signed-off-by: default avatarTeYuan Wang <kamewang@google.com>
(cherry picked from commit 5e9b1d82fd78cc6e91d18892e117341fa36ad315)
Signed-off-by: default avatarHridya Valsaraju <hridya@google.com>
parent 69672dd5
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -1430,6 +1430,43 @@ struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name)
}
EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);

/**
 * thermal_zone_get_cdev_by_name() - search for a cooling device and returns
 * its ref.
 * @name: thermal cdev name to fetch the temperature
 *
 * When only one cdev is found with the passed name, returns a reference to it.
 *
 * Return: On success returns a reference to an unique thermal cooling device
 * with matching name equals to @name, an ERR_PTR otherwise (-EINVAL for
 * invalid paramenters, -ENODEV for not found and -EEXIST for multiple matches).
 */
struct thermal_cooling_device *thermal_zone_get_cdev_by_name(const char *name)
{
	struct thermal_cooling_device *pos = NULL, *ref = ERR_PTR(-EINVAL);
	unsigned int found = 0;

	if (!name)
		return ref;

	mutex_lock(&thermal_list_lock);
	list_for_each_entry(pos, &thermal_cdev_list, node)
		if (!strncasecmp(name, pos->type, THERMAL_NAME_LENGTH)) {
			found++;
			ref = pos;
		}
	mutex_unlock(&thermal_list_lock);

	/* nothing has been found, thus an error code for it */
	if (found == 0)
		return ERR_PTR(-ENODEV);
	if (found > 1)
		return ERR_PTR(-EEXIST);
	return ref;

}
EXPORT_SYMBOL_GPL(thermal_zone_get_cdev_by_name);

#ifdef CONFIG_NET
static const struct genl_multicast_group thermal_event_mcgrps[] = {
	{ .name = THERMAL_GENL_MCAST_GROUP_NAME, },
+4 −0
Original line number Diff line number Diff line
@@ -527,6 +527,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_cooling_device *thermal_zone_get_cdev_by_name(const char *name);
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);
@@ -591,6 +592,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_cooling_device *thermal_zone_get_cdev_by_name(
		const char *name)
{ return ERR_PTR(-ENODEV); }
static inline int thermal_zone_get_temp(
		struct thermal_zone_device *tz, int *temp)
{ return -ENODEV; }