Lines 96-98
int cpuidle_register_governor(struct cpuidle_governor *gov)
Link Here
|
96 |
|
96 |
|
97 |
return ret; |
97 |
return ret; |
98 |
} |
98 |
} |
|
|
99 |
|
100 |
/** |
101 |
* cpuidle_replace_governor - find a replacement governor |
102 |
* @exclude_rating: the rating that will be skipped while looking for |
103 |
* new governor. |
104 |
*/ |
105 |
static struct cpuidle_governor *cpuidle_replace_governor(int exclude_rating) |
106 |
{ |
107 |
struct cpuidle_governor *gov; |
108 |
struct cpuidle_governor *ret_gov = NULL; |
109 |
unsigned int max_rating = 0; |
110 |
|
111 |
list_for_each_entry(gov, &cpuidle_governors, governor_list) { |
112 |
if (gov->rating == exclude_rating) |
113 |
continue; |
114 |
if (gov->rating > max_rating) { |
115 |
max_rating = gov->rating; |
116 |
ret_gov = gov; |
117 |
} |
118 |
} |
119 |
|
120 |
return ret_gov; |
121 |
} |
122 |
|
123 |
/** |
124 |
* cpuidle_unregister_governor - unregisters a governor |
125 |
* @gov: the governor |
126 |
*/ |
127 |
void cpuidle_unregister_governor(struct cpuidle_governor *gov) |
128 |
{ |
129 |
if (!gov) |
130 |
return; |
131 |
|
132 |
mutex_lock(&cpuidle_lock); |
133 |
if (gov == cpuidle_curr_governor) { |
134 |
struct cpuidle_governor *new_gov; |
135 |
new_gov = cpuidle_replace_governor(gov->rating); |
136 |
cpuidle_switch_governor(new_gov); |
137 |
} |
138 |
list_del(&gov->governor_list); |
139 |
mutex_unlock(&cpuidle_lock); |
140 |
} |
141 |
|