diff options
| -rw-r--r-- | drivers/thermal/thermal_core.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 02f57af04e3f..71b0ec0c370d 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c | |||
| @@ -56,10 +56,15 @@ static LIST_HEAD(thermal_governor_list); | |||
| 56 | static DEFINE_MUTEX(thermal_list_lock); | 56 | static DEFINE_MUTEX(thermal_list_lock); |
| 57 | static DEFINE_MUTEX(thermal_governor_lock); | 57 | static DEFINE_MUTEX(thermal_governor_lock); |
| 58 | 58 | ||
| 59 | static struct thermal_governor *def_governor; | ||
| 60 | |||
| 59 | static struct thermal_governor *__find_governor(const char *name) | 61 | static struct thermal_governor *__find_governor(const char *name) |
| 60 | { | 62 | { |
| 61 | struct thermal_governor *pos; | 63 | struct thermal_governor *pos; |
| 62 | 64 | ||
| 65 | if (!name || !name[0]) | ||
| 66 | return def_governor; | ||
| 67 | |||
| 63 | list_for_each_entry(pos, &thermal_governor_list, governor_list) | 68 | list_for_each_entry(pos, &thermal_governor_list, governor_list) |
| 64 | if (!strnicmp(name, pos->name, THERMAL_NAME_LENGTH)) | 69 | if (!strnicmp(name, pos->name, THERMAL_NAME_LENGTH)) |
| 65 | return pos; | 70 | return pos; |
| @@ -82,17 +87,23 @@ int thermal_register_governor(struct thermal_governor *governor) | |||
| 82 | if (__find_governor(governor->name) == NULL) { | 87 | if (__find_governor(governor->name) == NULL) { |
| 83 | err = 0; | 88 | err = 0; |
| 84 | list_add(&governor->governor_list, &thermal_governor_list); | 89 | list_add(&governor->governor_list, &thermal_governor_list); |
| 90 | if (!def_governor && !strncmp(governor->name, | ||
| 91 | DEFAULT_THERMAL_GOVERNOR, THERMAL_NAME_LENGTH)) | ||
| 92 | def_governor = governor; | ||
| 85 | } | 93 | } |
| 86 | 94 | ||
| 87 | mutex_lock(&thermal_list_lock); | 95 | mutex_lock(&thermal_list_lock); |
| 88 | 96 | ||
| 89 | list_for_each_entry(pos, &thermal_tz_list, node) { | 97 | list_for_each_entry(pos, &thermal_tz_list, node) { |
| 98 | /* | ||
| 99 | * only thermal zones with specified tz->tzp->governor_name | ||
| 100 | * may run with tz->govenor unset | ||
| 101 | */ | ||
| 90 | if (pos->governor) | 102 | if (pos->governor) |
| 91 | continue; | 103 | continue; |
| 92 | if (pos->tzp) | 104 | |
| 93 | name = pos->tzp->governor_name; | 105 | name = pos->tzp->governor_name; |
| 94 | else | 106 | |
| 95 | name = DEFAULT_THERMAL_GOVERNOR; | ||
| 96 | if (!strnicmp(name, governor->name, THERMAL_NAME_LENGTH)) | 107 | if (!strnicmp(name, governor->name, THERMAL_NAME_LENGTH)) |
| 97 | pos->governor = governor; | 108 | pos->governor = governor; |
| 98 | } | 109 | } |
| @@ -342,8 +353,8 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz) | |||
| 342 | static void handle_non_critical_trips(struct thermal_zone_device *tz, | 353 | static void handle_non_critical_trips(struct thermal_zone_device *tz, |
| 343 | int trip, enum thermal_trip_type trip_type) | 354 | int trip, enum thermal_trip_type trip_type) |
| 344 | { | 355 | { |
| 345 | if (tz->governor) | 356 | tz->governor ? tz->governor->throttle(tz, trip) : |
| 346 | tz->governor->throttle(tz, trip); | 357 | def_governor->throttle(tz, trip); |
| 347 | } | 358 | } |
| 348 | 359 | ||
| 349 | static void handle_critical_trips(struct thermal_zone_device *tz, | 360 | static void handle_critical_trips(struct thermal_zone_device *tz, |
| @@ -1533,7 +1544,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, | |||
| 1533 | if (tz->tzp) | 1544 | if (tz->tzp) |
| 1534 | tz->governor = __find_governor(tz->tzp->governor_name); | 1545 | tz->governor = __find_governor(tz->tzp->governor_name); |
| 1535 | else | 1546 | else |
| 1536 | tz->governor = __find_governor(DEFAULT_THERMAL_GOVERNOR); | 1547 | tz->governor = def_governor; |
| 1537 | 1548 | ||
| 1538 | mutex_unlock(&thermal_governor_lock); | 1549 | mutex_unlock(&thermal_governor_lock); |
| 1539 | 1550 | ||
