aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.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/acpi/thermal.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/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 9fe90e9fecb5..d7ef69d835f2 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -729,11 +729,9 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip,
729 return 0; 729 return 0;
730} 730}
731 731
732typedef int (*cb)(struct thermal_zone_device *, int,
733 struct thermal_cooling_device *);
734static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, 732static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
735 struct thermal_cooling_device *cdev, 733 struct thermal_cooling_device *cdev,
736 cb action) 734 bool bind)
737{ 735{
738 struct acpi_device *device = cdev->devdata; 736 struct acpi_device *device = cdev->devdata;
739 struct acpi_thermal *tz = thermal->devdata; 737 struct acpi_thermal *tz = thermal->devdata;
@@ -757,11 +755,19 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
757 i++) { 755 i++) {
758 handle = tz->trips.passive.devices.handles[i]; 756 handle = tz->trips.passive.devices.handles[i];
759 status = acpi_bus_get_device(handle, &dev); 757 status = acpi_bus_get_device(handle, &dev);
760 if (ACPI_SUCCESS(status) && (dev == device)) { 758 if (ACPI_FAILURE(status) || dev != device)
761 result = action(thermal, trip, cdev); 759 continue;
762 if (result) 760 if (bind)
763 goto failed; 761 result =
764 } 762 thermal_zone_bind_cooling_device
763 (thermal, trip, cdev,
764 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
765 else
766 result =
767 thermal_zone_unbind_cooling_device
768 (thermal, trip, cdev);
769 if (result)
770 goto failed;
765 } 771 }
766 } 772 }
767 773
@@ -774,11 +780,17 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
774 j++) { 780 j++) {
775 handle = tz->trips.active[i].devices.handles[j]; 781 handle = tz->trips.active[i].devices.handles[j];
776 status = acpi_bus_get_device(handle, &dev); 782 status = acpi_bus_get_device(handle, &dev);
777 if (ACPI_SUCCESS(status) && (dev == device)) { 783 if (ACPI_FAILURE(status) || dev != device)
778 result = action(thermal, trip, cdev); 784 continue;
779 if (result) 785 if (bind)
780 goto failed; 786 result = thermal_zone_bind_cooling_device
781 } 787 (thermal, trip, cdev,
788 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
789 else
790 result = thermal_zone_unbind_cooling_device
791 (thermal, trip, cdev);
792 if (result)
793 goto failed;
782 } 794 }
783 } 795 }
784 796
@@ -786,7 +798,14 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
786 handle = tz->devices.handles[i]; 798 handle = tz->devices.handles[i];
787 status = acpi_bus_get_device(handle, &dev); 799 status = acpi_bus_get_device(handle, &dev);
788 if (ACPI_SUCCESS(status) && (dev == device)) { 800 if (ACPI_SUCCESS(status) && (dev == device)) {
789 result = action(thermal, -1, cdev); 801 if (bind)
802 result = thermal_zone_bind_cooling_device
803 (thermal, -1, cdev,
804 THERMAL_NO_LIMIT,
805 THERMAL_NO_LIMIT);
806 else
807 result = thermal_zone_unbind_cooling_device
808 (thermal, -1, cdev);
790 if (result) 809 if (result)
791 goto failed; 810 goto failed;
792 } 811 }
@@ -800,16 +819,14 @@ static int
800acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, 819acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
801 struct thermal_cooling_device *cdev) 820 struct thermal_cooling_device *cdev)
802{ 821{
803 return acpi_thermal_cooling_device_cb(thermal, cdev, 822 return acpi_thermal_cooling_device_cb(thermal, cdev, true);
804 thermal_zone_bind_cooling_device);
805} 823}
806 824
807static int 825static int
808acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, 826acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
809 struct thermal_cooling_device *cdev) 827 struct thermal_cooling_device *cdev)
810{ 828{
811 return acpi_thermal_cooling_device_cb(thermal, cdev, 829 return acpi_thermal_cooling_device_cb(thermal, cdev, false);
812 thermal_zone_unbind_cooling_device);
813} 830}
814 831
815static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { 832static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {