aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/processor_throttling.c140
-rw-r--r--include/acpi/processor.h7
2 files changed, 79 insertions, 68 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1bae2e42a7..3a2e9a6018 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -44,18 +44,18 @@
44#define _COMPONENT ACPI_PROCESSOR_COMPONENT 44#define _COMPONENT ACPI_PROCESSOR_COMPONENT
45ACPI_MODULE_NAME("processor_throttling"); 45ACPI_MODULE_NAME("processor_throttling");
46 46
47static int acpi_processor_get_throttling (struct acpi_processor *pr); 47static int acpi_processor_get_throttling(struct acpi_processor *pr);
48int acpi_processor_set_throttling (struct acpi_processor *pr, int state); 48int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
49 49
50static int acpi_processor_get_platform_limit(struct acpi_processor *pr) 50static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
51{ 51{
52 acpi_status status = 0; 52 acpi_status status = 0;
53 unsigned long tpc = 0; 53 unsigned long tpc = 0;
54 54
55 if(!pr) 55 if (!pr)
56 return -EINVAL; 56 return -EINVAL;
57 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc); 57 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
58 if(ACPI_FAILURE(status) && status != AE_NOT_FOUND){ 58 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
59 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC")); 59 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC"));
60 return -ENODEV; 60 return -ENODEV;
61 } 61 }
@@ -102,7 +102,8 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
102 if ((obj.type != ACPI_TYPE_BUFFER) 102 if ((obj.type != ACPI_TYPE_BUFFER)
103 || (obj.buffer.length < sizeof(struct acpi_ptc_register)) 103 || (obj.buffer.length < sizeof(struct acpi_ptc_register))
104 || (obj.buffer.pointer == NULL)) { 104 || (obj.buffer.pointer == NULL)) {
105 printk(KERN_ERR PREFIX "Invalid _PTC data (control_register)\n"); 105 printk(KERN_ERR PREFIX
106 "Invalid _PTC data (control_register)\n");
106 result = -EFAULT; 107 result = -EFAULT;
107 goto end; 108 goto end;
108 } 109 }
@@ -124,9 +125,9 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
124 } 125 }
125 126
126 memcpy(&pr->throttling.status_register, obj.buffer.pointer, 127 memcpy(&pr->throttling.status_register, obj.buffer.pointer,
127 sizeof(struct acpi_ptc_register)); 128 sizeof(struct acpi_ptc_register));
128 129
129 end: 130 end:
130 kfree(buffer.pointer); 131 kfree(buffer.pointer);
131 132
132 return result; 133 return result;
@@ -168,7 +169,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
168 169
169 for (i = 0; i < pr->throttling.state_count; i++) { 170 for (i = 0; i < pr->throttling.state_count; i++) {
170 171
171 struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[i]); 172 struct acpi_processor_tx_tss *tx =
173 (struct acpi_processor_tx_tss *)&(pr->throttling.
174 states_tss[i]);
172 175
173 state.length = sizeof(struct acpi_processor_tx_tss); 176 state.length = sizeof(struct acpi_processor_tx_tss);
174 state.pointer = tx; 177 state.pointer = tx;
@@ -186,7 +189,7 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
186 189
187 if (!tx->freqpercentage) { 190 if (!tx->freqpercentage) {
188 printk(KERN_ERR PREFIX 191 printk(KERN_ERR PREFIX
189 "Invalid _TSS data: freq is zero\n"); 192 "Invalid _TSS data: freq is zero\n");
190 result = -EFAULT; 193 result = -EFAULT;
191 kfree(pr->throttling.states_tss); 194 kfree(pr->throttling.states_tss);
192 goto end; 195 goto end;
@@ -198,14 +201,14 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
198 201
199 return result; 202 return result;
200} 203}
201static int acpi_processor_get_tsd(struct acpi_processor *pr) 204static int acpi_processor_get_tsd(struct acpi_processor *pr)
202{ 205{
203 int result = 0; 206 int result = 0;
204 acpi_status status = AE_OK; 207 acpi_status status = AE_OK;
205 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 208 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
206 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"}; 209 struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
207 struct acpi_buffer state = {0, NULL}; 210 struct acpi_buffer state = { 0, NULL };
208 union acpi_object *tsd = NULL; 211 union acpi_object *tsd = NULL;
209 struct acpi_tsd_package *pdomain; 212 struct acpi_tsd_package *pdomain;
210 213
211 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer); 214 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer);
@@ -232,7 +235,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
232 state.pointer = pdomain; 235 state.pointer = pdomain;
233 236
234 status = acpi_extract_package(&(tsd->package.elements[0]), 237 status = acpi_extract_package(&(tsd->package.elements[0]),
235 &format, &state); 238 &format, &state);
236 if (ACPI_FAILURE(status)) { 239 if (ACPI_FAILURE(status)) {
237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); 240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
238 result = -EFAULT; 241 result = -EFAULT;
@@ -251,7 +254,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
251 goto end; 254 goto end;
252 } 255 }
253 256
254end: 257 end:
255 kfree(buffer.pointer); 258 kfree(buffer.pointer);
256 return result; 259 return result;
257} 260}
@@ -266,7 +269,6 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
266 u32 duty_mask = 0; 269 u32 duty_mask = 0;
267 u32 duty_value = 0; 270 u32 duty_value = 0;
268 271
269
270 if (!pr) 272 if (!pr)
271 return -EINVAL; 273 return -EINVAL;
272 274
@@ -306,65 +308,75 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
306 return 0; 308 return 0;
307} 309}
308 310
309static int acpi_read_throttling_status(struct acpi_processor_throttling *throttling) 311static int acpi_read_throttling_status(struct acpi_processor_throttling
312 *throttling)
310{ 313{
311 int value = -1; 314 int value = -1;
312 switch (throttling->status_register.space_id) { 315 switch (throttling->status_register.space_id) {
313 case ACPI_ADR_SPACE_SYSTEM_IO: 316 case ACPI_ADR_SPACE_SYSTEM_IO:
314 acpi_os_read_port((acpi_io_address)throttling->status_register.address, 317 acpi_os_read_port((acpi_io_address) throttling->status_register.
315 &value, 318 address, &value,
316 (u32)throttling->status_register.bit_width*8); 319 (u32) throttling->status_register.bit_width *
320 8);
317 break; 321 break;
318 case ACPI_ADR_SPACE_FIXED_HARDWARE: 322 case ACPI_ADR_SPACE_FIXED_HARDWARE:
319 printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n"); 323 printk(KERN_ERR PREFIX
324 "HARDWARE addr space,NOT supported yet\n");
320 break; 325 break;
321 default: 326 default:
322 printk(KERN_ERR PREFIX "Unknown addr space %d\n", 327 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
323 (u32) (throttling->status_register.space_id)); 328 (u32) (throttling->status_register.space_id));
324 } 329 }
325 return value; 330 return value;
326} 331}
327 332
328static int acpi_write_throttling_state(struct acpi_processor_throttling *throttling,int value) 333static int acpi_write_throttling_state(struct acpi_processor_throttling
334 *throttling, int value)
329{ 335{
330 int ret = -1; 336 int ret = -1;
331 337
332 switch (throttling->control_register.space_id) { 338 switch (throttling->control_register.space_id) {
333 case ACPI_ADR_SPACE_SYSTEM_IO: 339 case ACPI_ADR_SPACE_SYSTEM_IO:
334 acpi_os_write_port((acpi_io_address)throttling->control_register.address, 340 acpi_os_write_port((acpi_io_address) throttling->
335 value, 341 control_register.address, value,
336 (u32)throttling->control_register.bit_width*8); 342 (u32) throttling->control_register.
343 bit_width * 8);
337 ret = 0; 344 ret = 0;
338 break; 345 break;
339 case ACPI_ADR_SPACE_FIXED_HARDWARE: 346 case ACPI_ADR_SPACE_FIXED_HARDWARE:
340 printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n"); 347 printk(KERN_ERR PREFIX
348 "HARDWARE addr space,NOT supported yet\n");
341 break; 349 break;
342 default: 350 default:
343 printk(KERN_ERR PREFIX "Unknown addr space %d\n", 351 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
344 (u32) (throttling->control_register.space_id)); 352 (u32) (throttling->control_register.space_id));
345 } 353 }
346 return ret;