aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2012-10-09 01:35:52 -0400
committerLen Brown <len.brown@intel.com>2012-10-09 01:35:52 -0400
commit29b19e250434c6193c8b8e4c34c9c6284dd4f101 (patch)
tree8a1c8e308c9ae964f7fb612e921e10cf4c30ba15 /drivers/acpi/thermal.c
parent125c4c706b680c7831f0966ff873c1ad0354ec25 (diff)
parentc072fed95c9855a920c114d7fa3351f0f54ea06e (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux into thermal
Conflicts: drivers/staging/omap-thermal/omap-thermal-common. OMAP supplied dummy TC1 and TC2, at the same time that the thermal tree removed them from thermal_zone_device_register() drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c propogate the upstream MAX_IDR_LEVEL re-name to prevent a build failure Previously-fixed-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c93
1 files changed, 71 insertions, 22 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index edda74a43406..804204d41999 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -708,6 +708,40 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
708 return -EINVAL; 708 return -EINVAL;
709} 709}
710 710
711static int thermal_get_trend(struct thermal_zone_device *thermal,
712 int trip, enum thermal_trend *trend)
713{
714 struct acpi_thermal *tz = thermal->devdata;
715 enum thermal_trip_type type;
716 int i;
717
718 if (thermal_get_trip_type(thermal, trip, &type))
719 return -EINVAL;
720
721 if (type == THERMAL_TRIP_ACTIVE) {
722 /* aggressive active cooling */
723 *trend = THERMAL_TREND_RAISING;
724 return 0;
725 }
726
727 /*
728 * tz->temperature has already been updated by generic thermal layer,
729 * before this callback being invoked
730 */
731 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
732 + (tz->trips.passive.tc2
733 * (tz->temperature - tz->trips.passive.temperature));
734
735 if (i > 0)
736 *trend = THERMAL_TREND_RAISING;
737 else if (i < 0)
738 *trend = THERMAL_TREND_DROPPING;
739 else
740 *trend = THERMAL_TREND_STABLE;
741 return 0;
742}
743
744
711static int thermal_notify(struct thermal_zone_device *thermal, int trip, 745static int thermal_notify(struct thermal_zone_device *thermal, int trip,
712 enum thermal_trip_type trip_type) 746 enum thermal_trip_type trip_type)
713{ 747{
@@ -731,11 +765,9 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip,
731 return 0; 765 return 0;
732} 766}
733 767
734typedef int (*cb)(struct thermal_zone_device *, int,
735 struct thermal_cooling_device *);
736static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, 768static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
737 struct thermal_cooling_device *cdev, 769 struct thermal_cooling_device *cdev,
738 cb action) 770 bool bind)
739{ 771{
740 struct acpi_device *device = cdev->devdata; 772 struct acpi_device *device = cdev->devdata;
741 struct acpi_thermal *tz = thermal->devdata; 773 struct acpi_thermal *tz = thermal->devdata;
@@ -759,11 +791,19 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
759 i++) { 791 i++) {
760 handle = tz->trips.passive.devices.handles[i]; 792 handle = tz->trips.passive.devices.handles[i];
761 status = acpi_bus_get_device(handle, &dev); 793 status = acpi_bus_get_device(handle, &dev);
762 if (ACPI_SUCCESS(status) && (dev == device)) { 794 if (ACPI_FAILURE(status) || dev != device)
763 result = action(thermal, trip, cdev); 795 continue;
764 if (result) 796 if (bind)
765 goto failed; 797 result =
766 } 798 thermal_zone_bind_cooling_device
799 (thermal, trip, cdev,
800 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
801 else
802 result =
803 thermal_zone_unbind_cooling_device
804 (thermal, trip, cdev);
805 if (result)
806 goto failed;
767 } 807 }
768 } 808 }
769 809
@@ -776,11 +816,17 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
776 j++) { 816 j++) {
777 handle = tz->trips.active[i].devices.handles[j]; 817 handle = tz->trips.active[i].devices.handles[j];
778 status = acpi_bus_get_device(handle, &dev); 818 status = acpi_bus_get_device(handle, &dev);
779 if (ACPI_SUCCESS(status) && (dev == device)) { 819 if (ACPI_FAILURE(status) || dev != device)
780 result = action(thermal, trip, cdev); 820 continue;
781 if (result) 821 if (bind)
782 goto failed; 822 result = thermal_zone_bind_cooling_device
783 } 823 (thermal, trip, cdev,
824 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
825 else
826 result = thermal_zone_unbind_cooling_device
827 (thermal, trip, cdev);
828 if (result)
829 goto failed;
784 } 830 }
785 } 831 }
786 832
@@ -788,7 +834,14 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
788 handle = tz->devices.handles[i]; 834 handle = tz->devices.handles[i];
789 status = acpi_bus_get_device(handle, &dev); 835 status = acpi_bus_get_device(handle, &dev);
790 if (ACPI_SUCCESS(status) && (dev == device)) { 836 if (ACPI_SUCCESS(status) && (dev == device)) {
791 result = action(thermal, -1, cdev); 837 if (bind)
838 result = thermal_zone_bind_cooling_device
839 (thermal, -1, cdev,
840 THERMAL_NO_LIMIT,
841 THERMAL_NO_LIMIT);
842 else
843 result = thermal_zone_unbind_cooling_device
844 (thermal, -1, cdev);
792 if (result) 845 if (result)
793 goto failed; 846 goto failed;
794 } 847 }
@@ -802,16 +855,14 @@ static int
802acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, 855acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
803 struct thermal_cooling_device *cdev) 856 struct thermal_cooling_device *cdev)
804{ 857{
805 return acpi_thermal_cooling_device_cb(thermal, cdev, 858 return acpi_thermal_cooling_device_cb(thermal, cdev, true);
806 thermal_zone_bind_cooling_device);
807} 859}
808 860
809static int 861static int
810acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, 862acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
811 struct thermal_cooling_device *cdev) 863 struct thermal_cooling_device *cdev)
812{ 864{
813 return acpi_thermal_cooling_device_cb(thermal, cdev, 865 return acpi_thermal_cooling_device_cb(thermal, cdev, false);
814 thermal_zone_unbind_cooling_device);
815} 866}
816 867
817static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { 868static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
@@ -823,6 +874,7 @@ static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
823 .get_trip_type = thermal_get_trip_type, 874 .get_trip_type = thermal_get_trip_type,
824 .get_trip_temp = thermal_get_trip_temp, 875 .get_trip_temp = thermal_get_trip_temp,
825 .get_crit_temp = thermal_get_crit_temp, 876 .get_crit_temp = thermal_get_crit_temp,
877 .get_trend = thermal_get_trend,
826 .notify = thermal_notify, 878 .notify = thermal_notify,
827}; 879};
828 880
@@ -849,15 +901,12 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
849 tz->thermal_zone = 901 tz->thermal_zone =
850 thermal_zone_device_register("acpitz", trips, 0, tz, 902 thermal_zone_device_register("acpitz", trips, 0, tz,
851 &acpi_thermal_zone_ops, 903 &acpi_thermal_zone_ops,
852 tz->trips.passive.tc1,
853 tz->trips.passive.tc2,
854 tz->trips.passive.tsp*100, 904 tz->trips.passive.tsp*100,
855 tz->polling_frequency*100); 905 tz->polling_frequency*100);
856 else 906 else
857 tz->thermal_zone = 907 tz->thermal_zone =
858 thermal_zone_device_register("acpitz", trips, 0, tz, 908 thermal_zone_device_register("acpitz", trips, 0, tz,
859 &acpi_thermal_zone_ops, 909 &acpi_thermal_zone_ops, 0,
860 0, 0, 0,
861 tz->polling_frequency*100); 910 tz->polling_frequency*100);
862 if (IS_ERR(tz->thermal_zone)) 911 if (IS_ERR(tz->thermal_zone))
863 return -ENODEV; 912 return -ENODEV;