aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_throttling.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_throttling.c')
-rw-r--r--drivers/acpi/processor_throttling.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 2de40bd5fdff..d044ec519db0 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -55,13 +55,12 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
55 u32 duty_mask = 0; 55 u32 duty_mask = 0;
56 u32 duty_value = 0; 56 u32 duty_value = 0;
57 57
58 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
59 58
60 if (!pr) 59 if (!pr)
61 return_VALUE(-EINVAL); 60 return -EINVAL;
62 61
63 if (!pr->flags.throttling) 62 if (!pr->flags.throttling)
64 return_VALUE(-ENODEV); 63 return -ENODEV;
65 64
66 pr->throttling.state = 0; 65 pr->throttling.state = 0;
67 66
@@ -93,7 +92,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
93 "Throttling state is T%d (%d%% throttling applied)\n", 92 "Throttling state is T%d (%d%% throttling applied)\n",
94 state, pr->throttling.states[state].performance)); 93 state, pr->throttling.states[state].performance));
95 94
96 return_VALUE(0); 95 return 0;
97} 96}
98 97
99int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 98int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
@@ -102,19 +101,18 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
102 u32 duty_mask = 0; 101 u32 duty_mask = 0;
103 u32 duty_value = 0; 102 u32 duty_value = 0;
104 103
105 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
106 104
107 if (!pr) 105 if (!pr)
108 return_VALUE(-EINVAL); 106 return -EINVAL;
109 107
110 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 108 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
111 return_VALUE(-EINVAL); 109 return -EINVAL;
112 110
113 if (!pr->flags.throttling) 111 if (!pr->flags.throttling)
114 return_VALUE(-ENODEV); 112 return -ENODEV;
115 113
116 if (state == pr->throttling.state) 114 if (state == pr->throttling.state)
117 return_VALUE(0); 115 return 0;
118 116
119 /* 117 /*
120 * Calculate the duty_value and duty_mask. 118 * Calculate the duty_value and duty_mask.
@@ -165,7 +163,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
165 (pr->throttling.states[state].performance ? pr-> 163 (pr->throttling.states[state].performance ? pr->
166 throttling.states[state].performance / 10 : 0))); 164 throttling.states[state].performance / 10 : 0)));
167 165
168 return_VALUE(0); 166 return 0;
169} 167}
170 168
171int acpi_processor_get_throttling_info(struct acpi_processor *pr) 169int acpi_processor_get_throttling_info(struct acpi_processor *pr)
@@ -174,7 +172,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
174 int step = 0; 172 int step = 0;
175 int i = 0; 173 int i = 0;
176 174
177 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
178 175
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 176 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
180 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 177 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -183,21 +180,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
183 pr->throttling.duty_width)); 180 pr->throttling.duty_width));
184 181
185 if (!pr) 182 if (!pr)
186 return_VALUE(-EINVAL); 183 return -EINVAL;
187 184
188 /* TBD: Support ACPI 2.0 objects */ 185 /* TBD: Support ACPI 2.0 objects */
189 186
190 if (!pr->throttling.address) { 187 if (!pr->throttling.address) {
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 188 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
192 return_VALUE(0); 189 return 0;
193 } else if (!pr->throttling.duty_width) { 190 } else if (!pr->throttling.duty_width) {
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); 191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
195 return_VALUE(0); 192 return 0;
196 } 193 }
197 /* TBD: Support duty_cycle values that span bit 4. */ 194 /* TBD: Support duty_cycle values that span bit 4. */
198 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { 195 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
199 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); 196 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
200 return_VALUE(0); 197 return 0;
201 } 198 }
202 199
203 /* 200 /*
@@ -208,7 +205,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
208 if (errata.piix4.throttle) { 205 if (errata.piix4.throttle) {
209 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
210 "Throttling not supported on PIIX4 A- or B-step\n")); 207 "Throttling not supported on PIIX4 A- or B-step\n"));
211 return_VALUE(0); 208 return 0;
212 } 209 }
213 210
214 pr->throttling.state_count = 1 << acpi_fadt.duty_width; 211 pr->throttling.state_count = 1 << acpi_fadt.duty_width;
@@ -254,7 +251,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
254 if (result) 251 if (result)
255 pr->flags.throttling = 0; 252 pr->flags.throttling = 0;
256 253
257 return_VALUE(result); 254 return result;
258} 255}
259 256
260/* proc interface */ 257/* proc interface */
@@ -266,7 +263,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
266 int i = 0; 263 int i = 0;
267 int result = 0; 264 int result = 0;
268 265
269 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
270 266
271 if (!pr) 267 if (!pr)
272 goto end; 268 goto end;
@@ -296,7 +292,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
296 throttling.states[i].performance / 10 : 0)); 292 throttling.states[i].performance / 10 : 0));
297 293
298 end: 294 end:
299 return_VALUE(0); 295 return 0;
300} 296}
301 297
302static int acpi_processor_throttling_open_fs(struct inode *inode, 298static int acpi_processor_throttling_open_fs(struct inode *inode,
@@ -315,13 +311,12 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
315 struct acpi_processor *pr = (struct acpi_processor *)m->private; 311 struct acpi_processor *pr = (struct acpi_processor *)m->private;
316 char state_string[12] = { '\0' }; 312 char state_string[12] = { '\0' };
317 313
318 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
319 314
320 if (!pr || (count > sizeof(state_string) - 1)) 315 if (!pr || (count > sizeof(state_string) - 1))
321 return_VALUE(-EINVAL); 316 return -EINVAL;
322 317
323 if (copy_from_user(state_string, buffer, count)) 318 if (copy_from_user(state_string, buffer, count))
324 return_VALUE(-EFAULT); 319 return -EFAULT;
325 320
326 state_string[count] = '\0'; 321 state_string[count] = '\0';
327 322
@@ -329,9 +324,9 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
329 simple_strtoul(state_string, 324 simple_strtoul(state_string,
330 NULL, 0)); 325 NULL, 0));
331 if (result) 326 if (result)
332 return_VALUE(result); 327 return result;
333 328
334 return_VALUE(count); 329 return count;
335} 330}
336 331
337struct file_operations acpi_processor_throttling_fops = { 332struct file_operations acpi_processor_throttling_fops = {