Thermal: Fix to use read critical temperature when required
PATCH 1/1 Thermal: Fix to use read critical temperature when required
This patch modifies the code to use get_crit_temp instead of the normal get_trip_temp when critical threshold point is crossed or queried about.
--- drivers/thermal/thermal_sys.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/thermal/thermal_sys.c +13 -2
@@ -345,7 +345,10 @@ static void handle_critical_trips(struct thermal_zone_device *tz, {long trip_temp; - tz->ops->get_trip_temp (tz, trip, &trip_temp); +if (tz->ops->get_crit_temp) + tz->ops->get_crit_temp (tz, &trip_temp); +else + tz->ops->get_trip_temp (tz, trip, &trip_temp);/* If we have not crossed the trip_temp, we do not care. */ if (tz->temperature < trip_temp)
@@ -550,6 +553,7 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,struct thermal_zone_device *tz =to_thermal_zone (dev);int trip, ret;long temperature; +enum thermal_trip_type type;if (!tz->ops->get_trip_temp)return -EPERM ;
@@ -557,7 +561,14 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,if (!sscanf (attr->attr.name,"trip_point_%d_temp" , &trip))return -EINVAL ; - ret = tz->ops->get_trip_temp (tz, trip, &temperature); + ret = tz->ops->get_trip_type (tz, trip, &type); +if (ret) +return ret; + +if (type ==THERMAL_TRIP_CRITICAL && tz->ops->get_crit_temp) + ret = tz->ops->get_crit_temp (tz, &temperature); +else + ret = tz->ops->get_trip_temp (tz, trip, &temperature);if (ret)return ret;
Signature · 1 line
1.7.10.4
Zhang Rui
reviewerQuoted 4 lines · Amit Daniel Kachhap
This patch modifies the code to use
get_crit_tempinstead of the normalget_trip_tempwhen critical threshold point is crossed or queried about.
is there any problem in the current code?
Quoted 10 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- drivers/thermal/thermal_sys.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/thermal/thermal_sys.c +0
-0
drivers/thermal/thermal_sys.c static void handle_critical_trips(struct thermal_zone_device *tz, · line 352
Quoted 9 lines
drivers/thermal/thermal_sys.c +4
-1@@ -345,7 +345,10 @@ static void handle_critical_trips(struct thermal_zone_device *tz, {long trip_temp; - tz->ops->get_trip_temp (tz, trip, &trip_temp); +if (tz->ops->get_crit_temp) + tz->ops->get_crit_temp (tz, &trip_temp); +else + tz->ops->get_trip_temp (tz, trip, &trip_temp);
handle_critical_trips() can handle both active and hot trip points. this change will break HOT trip point.
Quoted 14 lines
drivers/thermal/thermal_sys.c +1
-0/* If we have not crossed the trip_temp, we do not care. */ if (tz->temperature < trip_temp)@@ -550,6 +553,7 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,struct thermal_zone_device *tz =to_thermal_zone (dev);int trip, ret;long temperature; +enum thermal_trip_type type;if (!tz->ops->get_trip_temp)return -EPERM ;@@ -557,7 +561,14 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,if (!sscanf (attr->attr.name,"trip_point_%d_temp" , &trip))return -EINVAL ;
drivers/thermal/thermal_sys.c trip_point_temp_show(struct device *dev, struct device_attribute *attr, · line 572
Quoted 10 lines
drivers/thermal/thermal_sys.c +8
-1- ret = tz->ops->get_trip_temp (tz, trip, &temperature); + ret = tz->ops->get_trip_type (tz, trip, &type); +if (ret) +return ret; + +if (type ==THERMAL_TRIP_CRITICAL && tz->ops->get_crit_temp) + ret = tz->ops->get_crit_temp (tz, &temperature); +else + ret = tz->ops->get_trip_temp (tz, trip, &temperature);
what's the benefit of using .get_crit_temp() instead of .get_trip_temp() for CRITICAL trip points here?
.get_trip_point can also get the critical trip point temperature.
instead, I think we could remove .get_crit_temp callback. for hwmon sysfs, we just need to use get_trip_type to find the critical trip point.
thanks,
rui
Quoted 70 lines
-----Original Message-----
From: Zhang, Rui
Sent: Friday, February 01, 2013 11:14 AM
To: Amit Daniel Kachhap
Cc: [email protected]; [email protected]; R, Durgadoss
Subject: Re: [PATCH] Thermal: Fix to use read critical temperature when requiredQuoted 4 lines · Amit Daniel Kachhap
This patch modifies the code to use
get_crit_tempinstead of the normalget_trip_tempwhen critical threshold point is crossed or queried about.is there any problem in the current code?
drivers/thermal/thermal_sys.c static void handle_critical_trips(struct
Quoted 10 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- drivers/thermal/thermal_sys.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/thermal/thermal_sys.c +0
-0@@ -345,7 +345,10 @@ static void handle_critical_trips(struct
thermal_zone_device*tz,drivers/thermal/thermal_sys.c static void handle_critical_trips(struct thermal_zone_device *tz, · line 352
Quoted 9 lines
drivers/thermal/thermal_sys.c +4
-1{long trip_temp; - tz->ops->get_trip_temp (tz, trip, &trip_temp); +if (tz->ops->get_crit_temp) + tz->ops->get_crit_temp (tz, &trip_temp); +else + tz->ops->get_trip_temp (tz, trip, &trip_temp);
handle_critical_trips()can handle both active and hot trip points. this change will break HOT trip point.drivers/thermal/thermal_sys.c trip_point_temp_show(struct device *dev, struct
Quoted 3 lines
drivers/thermal/thermal_sys.c +0
-0/* If we have not crossed the trip_temp, we do not care. */ if (tz->temperature < trip_temp)@@ -550,6 +553,7 @@ trip_point_temp_show(struct device *dev, struct
device_attribute*attr,drivers/thermal/thermal_sys.c trip_point_temp_show(struct device *dev, struct
Quoted 8 lines
drivers/thermal/thermal_sys.c +1
-0struct thermal_zone_device *tz =to_thermal_zone (dev);int trip, ret;long temperature; +enum thermal_trip_type type;if (!tz->ops->get_trip_temp)return -EPERM ;@@ -557,7 +561,14 @@ trip_point_temp_show(struct device *dev, struct
device_attribute*attr,drivers/thermal/thermal_sys.c trip_point_temp_show(struct device *dev, struct device_attribute *attr, · line 572
Quoted 13 lines
drivers/thermal/thermal_sys.c +8
-1if (!sscanf (attr->attr.name,"trip_point_%d_temp" , &trip))return -EINVAL ; - ret = tz->ops->get_trip_temp (tz, trip, &temperature); + ret = tz->ops->get_trip_type (tz, trip, &type); +if (ret) +return ret; + +if (type ==THERMAL_TRIP_CRITICAL && tz->ops->get_crit_temp) + ret = tz->ops->get_crit_temp (tz, &temperature); +else + ret = tz->ops->get_trip_temp (tz, trip, &temperature);what's the benefit of using .get_crit_temp() instead of .get_trip_temp() for CRITICAL trip points here?
.get_trip_point can also get the critical trip point temperature.
Quoted 1 line
instead, I think we could remove .get_crit_temp callback.
I agree with you Rui here :-)
Quoted 2 lines
for hwmon sysfs, we just need to use
get_trip_typeto find the critical trip point.
Yes, this should work.
Thanks,
Durga