aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_sys.c
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2012-06-26 04:35:57 -0400
committerZhang Rui <rui.zhang@intel.com>2012-09-24 02:44:36 -0400
commit9d99842f99d847191ebd0c28469d2c70fcc5bf9e (patch)
tree211624d5fbc557c1226b6270a96807acc3b383df /drivers/thermal/thermal_sys.c
parent74051ba50583a5880d4536c1d9333e2493ddfd76 (diff)
Thermal: set upper and lower limits
set upper and lower limits when binding a thermal cooling device to a thermal zone device. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers/thermal/thermal_sys.c')
-rw-r--r--drivers/thermal/thermal_sys.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index d78c6dc6b00a..b04fe2c4b0d5 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -315,8 +315,9 @@ passive_store(struct device *dev, struct device_attribute *attr,
315 if (!strncmp("Processor", cdev->type, 315 if (!strncmp("Processor", cdev->type,
316 sizeof("Processor"))) 316 sizeof("Processor")))
317 thermal_zone_bind_cooling_device(tz, 317 thermal_zone_bind_cooling_device(tz,
318 THERMAL_TRIPS_NONE, 318 THERMAL_TRIPS_NONE, cdev,
319 cdev); 319 THERMAL_NO_LIMIT,
320 THERMAL_NO_LIMIT);
320 } 321 }
321 mutex_unlock(&thermal_list_lock); 322 mutex_unlock(&thermal_list_lock);
322 if (!tz->passive_delay) 323 if (!tz->passive_delay)
@@ -801,7 +802,8 @@ static void thermal_zone_device_check(struct work_struct *work)
801 */ 802 */
802int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, 803int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
803 int trip, 804 int trip,
804 struct thermal_cooling_device *cdev) 805 struct thermal_cooling_device *cdev,
806 unsigned long upper, unsigned long lower)
805{ 807{
806 struct thermal_cooling_device_instance *dev; 808 struct thermal_cooling_device_instance *dev;
807 struct thermal_cooling_device_instance *pos; 809 struct thermal_cooling_device_instance *pos;
@@ -825,6 +827,15 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
825 if (tz != pos1 || cdev != pos2) 827 if (tz != pos1 || cdev != pos2)
826 return -EINVAL; 828 return -EINVAL;
827 829
830 cdev->ops->get_max_state(cdev, &max_state);
831
832 /* lower default 0, upper default max_state */
833 lower = lower == THERMAL_NO_LIMIT ? 0 : lower;
834 upper = upper == THERMAL_NO_LIMIT ? max_state : upper;
835
836 if (lower > upper || upper > max_state)
837 return -EINVAL;
838
828 dev = 839 dev =
829 kzalloc(sizeof(struct thermal_cooling_device_instance), GFP_KERNEL); 840 kzalloc(sizeof(struct thermal_cooling_device_instance), GFP_KERNEL);
830 if (!dev) 841 if (!dev)
@@ -832,10 +843,8 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
832 dev->tz = tz; 843 dev->tz = tz;
833 dev->cdev = cdev; 844 dev->cdev = cdev;
834 dev->trip = trip; 845 dev->trip = trip;
835 846 dev->upper = upper;
836 cdev->ops->get_max_state(cdev, &max_state); 847 dev->lower = lower;
837 dev->upper = max_state;
838 dev->lower = 0;
839 848
840 result = get_idr(&tz->idr, &tz->lock, &dev->id); 849 result = get_idr(&tz->idr, &tz->lock, &dev->id);
841 if (result) 850 if (result)