Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODROID-XU4 : update hack avoiding the invalid temperature by TMU broken #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions drivers/thermal/thermal_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ 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;
Expand Down Expand Up @@ -107,6 +111,30 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
*temp = tz->emul_temperature;
}

/* 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;
}

mutex_unlock(&tz->lock);
exit:
return ret;
Expand Down