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

Commit 1d0fd42f authored by Wei Ni's avatar Wei Ni Committed by Eduardo Valentin
Browse files

thermal: consistently use int for trip temp



The commit 17e8351a consistently use int for temperature,
however it missed a few in trip temperature and thermal_core.

In current codes, the trip->temperature used "unsigned long"
and zone->temperature used"int", if the temperature is negative
value, it will get wrong result when compare temperature with
trip temperature.

This patch can fix it.

Signed-off-by: default avatarWei Ni <wni@nvidia.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent 62e14f6f
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -688,7 +688,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
{
{
	struct thermal_zone_device *tz = to_thermal_zone(dev);
	struct thermal_zone_device *tz = to_thermal_zone(dev);
	int trip, ret;
	int trip, ret;
	unsigned long temperature;
	int temperature;


	if (!tz->ops->set_trip_temp)
	if (!tz->ops->set_trip_temp)
		return -EPERM;
		return -EPERM;
@@ -696,7 +696,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
	if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip))
	if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip))
		return -EINVAL;
		return -EINVAL;


	if (kstrtoul(buf, 10, &temperature))
	if (kstrtoint(buf, 10, &temperature))
		return -EINVAL;
		return -EINVAL;


	ret = tz->ops->set_trip_temp(tz, trip, temperature);
	ret = tz->ops->set_trip_temp(tz, trip, temperature);
@@ -899,9 +899,9 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
{
{
	struct thermal_zone_device *tz = to_thermal_zone(dev);
	struct thermal_zone_device *tz = to_thermal_zone(dev);
	int ret = 0;
	int ret = 0;
	unsigned long temperature;
	int temperature;


	if (kstrtoul(buf, 10, &temperature))
	if (kstrtoint(buf, 10, &temperature))
		return -EINVAL;
		return -EINVAL;


	if (!tz->ops->set_emul_temp) {
	if (!tz->ops->set_emul_temp) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -352,8 +352,8 @@ struct thermal_zone_of_device_ops {


struct thermal_trip {
struct thermal_trip {
	struct device_node *np;
	struct device_node *np;
	unsigned long int temperature;
	int temperature;
	unsigned long int hysteresis;
	int hysteresis;
	enum thermal_trip_type type;
	enum thermal_trip_type type;
};
};