summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/int340x_thermal
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2015-01-28 11:56:48 -0800
committerZhang Rui <rui.zhang@intel.com>2015-01-29 21:02:12 +0800
commit317d9dda0522c18eb230367c88601c2e46cda4f8 (patch)
tree27fb5b40515e4ebf1e99f2f1b73270caaf39acfe /drivers/thermal/int340x_thermal
parentac586e2d6afb1935246c75f0e27a5c628712dbfa (diff)
downloadlinux-317d9dda0522c18eb230367c88601c2e46cda4f8.tar.gz
linux-317d9dda0522c18eb230367c88601c2e46cda4f8.tar.bz2
linux-317d9dda0522c18eb230367c88601c2e46cda4f8.zip
Thermal/int340x: LPAT conversion for temperature
When LPAT table is present, we need to convert raw temperature to real temp using LPAT. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/int340x_thermal')
-rw-r--r--drivers/thermal/int340x_thermal/int340x_thermal_zone.c20
-rw-r--r--drivers/thermal/int340x_thermal/int340x_thermal_zone.h3
2 files changed, 20 insertions, 3 deletions
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
index 162e545cc93a..f88b08877025 100644
--- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
@@ -33,8 +33,17 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
if (ACPI_FAILURE(status))
return -EIO;
- /* _TMP returns the temperature in tenths of degrees Kelvin */
- *temp = DECI_KELVIN_TO_MILLICELSIUS(tmp);
+ if (d->lpat_table) {
+ int conv_temp;
+
+ conv_temp = acpi_lpat_raw_to_temp(d->lpat_table, (int)tmp);
+ if (conv_temp < 0)
+ return conv_temp;
+
+ *temp = (unsigned long)conv_temp * 10;
+ } else
+ /* _TMP returns the temperature in tenths of degrees Kelvin */
+ *temp = DECI_KELVIN_TO_MILLICELSIUS(tmp);
return 0;
}
@@ -227,6 +236,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
int34x_thermal_zone->act_trips[i].id = trip_cnt++;
int34x_thermal_zone->act_trips[i].valid = true;
}
+ int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table(
+ adev->handle);
int34x_thermal_zone->zone = thermal_zone_device_register(
acpi_device_bid(adev),
@@ -237,11 +248,13 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
0, 0);
if (IS_ERR(int34x_thermal_zone->zone)) {
ret = PTR_ERR(int34x_thermal_zone->zone);
- goto free_mem;
+ goto free_lpat;
}
return int34x_thermal_zone;
+free_lpat:
+ acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table);
free_mem:
kfree(int34x_thermal_zone);
return ERR_PTR(ret);
@@ -252,6 +265,7 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone
*int34x_thermal_zone)
{
thermal_zone_device_unregister(int34x_thermal_zone->zone);
+ acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table);
kfree(int34x_thermal_zone);
}
EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
index 11f2f5260c3a..9f38ab72c4bf 100644
--- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
+++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
@@ -16,6 +16,8 @@
#ifndef __INT340X_THERMAL_ZONE_H__
#define __INT340X_THERMAL_ZONE_H__
+#include <acpi/acpi_lpat.h>
+
#define INT340X_THERMAL_MAX_ACT_TRIP_COUNT 10
struct active_trip {
@@ -38,6 +40,7 @@ struct int34x_thermal_zone {
struct thermal_zone_device *zone;
struct thermal_zone_device_ops *override_ops;
void *priv_data;
+ struct acpi_lpat_conversion_table *lpat_table;
};
struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,