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

Commit 20f5f003 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "thermal-core: Fix to send correct trip type to get trip temperature"

parents 3afae425 152b118e
Loading
Loading
Loading
Loading
+36 −17
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
 *  Copyright (C) 2008 Intel Corp
 *  Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
 *  Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
 *  Copyright (c) 2013, The Linux Foundation. All rights reserved.
 *  Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
@@ -159,13 +159,43 @@ int sensor_get_id(char *name)
}
EXPORT_SYMBOL(sensor_get_id);

static void init_sensor_trip(struct sensor_info *sensor)
{
	int ret = 0, i = 0;
	enum thermal_trip_type type;

	for (i = 0; ((sensor->max_idx == -1) ||
		(sensor->min_idx == -1)) &&
		(sensor->tz->ops->get_trip_type) &&
		(i < sensor->tz->trips); i++) {

		sensor->tz->ops->get_trip_type(sensor->tz, i, &type);
		if (type == THERMAL_TRIP_CONFIGURABLE_HI)
			sensor->max_idx = i;
		if (type == THERMAL_TRIP_CONFIGURABLE_LOW)
			sensor->min_idx = i;
		type = 0;
	}

	ret = sensor->tz->ops->get_trip_temp(sensor->tz,
		sensor->min_idx, &sensor->threshold_min);
	if (ret)
		pr_err("Unable to get MIN trip temp. sensor:%d err:%d\n",
				sensor->sensor_id, ret);

	ret = sensor->tz->ops->get_trip_temp(sensor->tz,
		sensor->max_idx, &sensor->threshold_max);
	if (ret)
		pr_err("Unable to get MAX trip temp. sensor:%d err:%d\n",
				sensor->sensor_id, ret);
}

static int __update_sensor_thresholds(struct sensor_info *sensor)
{
	long max_of_low_thresh = LONG_MIN;
	long min_of_high_thresh = LONG_MAX;
	struct sensor_threshold *pos, *var;
	enum thermal_trip_type type;
	int i, ret = 0;
	int ret = 0;

	if (!sensor->tz->ops->set_trip_temp ||
		!sensor->tz->ops->activate_trip_type ||
@@ -175,19 +205,8 @@ static int __update_sensor_thresholds(struct sensor_info *sensor)
		goto update_done;
	}

	for (i = 0; ((sensor->max_idx == -1) || (sensor->min_idx == -1)) &&
		(sensor->tz->ops->get_trip_type) && (i < sensor->tz->trips);
		i++) {
		sensor->tz->ops->get_trip_type(sensor->tz, i, &type);
		if (type == THERMAL_TRIP_CONFIGURABLE_HI)
			sensor->max_idx = i;
		if (type == THERMAL_TRIP_CONFIGURABLE_LOW)
			sensor->min_idx = i;
		sensor->tz->ops->get_trip_temp(sensor->tz,
			THERMAL_TRIP_CONFIGURABLE_LOW, &sensor->threshold_min);
		sensor->tz->ops->get_trip_temp(sensor->tz,
			THERMAL_TRIP_CONFIGURABLE_HI, &sensor->threshold_max);
	}
	if ((sensor->max_idx == -1) || (sensor->min_idx == -1))
		init_sensor_trip(sensor);

	list_for_each_entry_safe(pos, var, &sensor->threshold_list, list) {
		if (!pos->active)
@@ -436,7 +455,7 @@ int sensor_init(struct thermal_zone_device *tz)

	sensor->sensor_id = tz->id;
	sensor->tz = tz;
	sensor->threshold_min = 0;
	sensor->threshold_min = LONG_MIN;
	sensor->threshold_max = LONG_MAX;
	sensor->max_idx = -1;
	sensor->min_idx = -1;