mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
ODROID-XU4: Update hack avoiding the invalid temperature by TMU broken
Change-Id: I6092834427950a50746535458e99bf7089212044
This commit is contained in:
committed by
Mauro (mdrjr) Ribeiro
parent
354551f602
commit
3ea56c07db
@@ -78,6 +78,9 @@ EXPORT_SYMBOL(get_thermal_instance);
|
||||
*
|
||||
* Return: On success returns 0, an error code otherwise
|
||||
*/
|
||||
#define CRITICAL_TEMP 120000
|
||||
int thermal_zone_data[4] = { 0, };
|
||||
|
||||
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
@@ -110,6 +113,30 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||
if (ret)
|
||||
dev_dbg(&tz->device, "Failed to get temperature: %d\n", ret);
|
||||
|
||||
/* save thermal_zone data */
|
||||
if (!ret)
|
||||
thermal_zone_data[tz->id] = *temp;
|
||||
/*
|
||||
* This case is that the thermal sensor is broken.
|
||||
* That's not real temperature. Set the fake temperature value in order to
|
||||
* avoid reaching the ciritical temperature.
|
||||
*/
|
||||
if ((thermal_zone_data[tz->id] > CRITICAL_TEMP) && (tz->id != 4)) {
|
||||
int i, broken_sensor = 0, correct_temp = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((thermal_zone_data[i] <= CRITICAL_TEMP) &&
|
||||
(correct_temp <= thermal_zone_data[i]))
|
||||
correct_temp = thermal_zone_data[i];
|
||||
if (thermal_zone_data[i] > CRITICAL_TEMP)
|
||||
broken_sensor++;
|
||||
}
|
||||
/*
|
||||
* if all thermal sensor broken then critical temperature data send
|
||||
* for system poweroff.
|
||||
*/
|
||||
*temp = (broken_sensor == 4) ? CRITICAL_TEMP : correct_temp;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user