ACPI: Lindent processor throttling code

Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
Len Brown 2007-06-02 00:15:25 -04:00
parent 01854e697a
commit ff55a9ceba
2 changed files with 79 additions and 68 deletions

View File

@ -102,7 +102,8 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
if ((obj.type != ACPI_TYPE_BUFFER)
|| (obj.buffer.length < sizeof(struct acpi_ptc_register))
|| (obj.buffer.pointer == NULL)) {
printk(KERN_ERR PREFIX "Invalid _PTC data (control_register)\n");
printk(KERN_ERR PREFIX
"Invalid _PTC data (control_register)\n");
result = -EFAULT;
goto end;
}
@ -168,7 +169,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
for (i = 0; i < pr->throttling.state_count; i++) {
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[i]);
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[i]);
state.length = sizeof(struct acpi_processor_tx_tss);
state.pointer = tx;
@ -266,7 +269,6 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
u32 duty_mask = 0;
u32 duty_value = 0;
if (!pr)
return -EINVAL;
@ -306,17 +308,20 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
return 0;
}
static int acpi_read_throttling_status(struct acpi_processor_throttling *throttling)
static int acpi_read_throttling_status(struct acpi_processor_throttling
*throttling)
{
int value = -1;
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
acpi_os_read_port((acpi_io_address)throttling->status_register.address,
&value,
(u32)throttling->status_register.bit_width*8);
acpi_os_read_port((acpi_io_address) throttling->status_register.
address, &value,
(u32) throttling->status_register.bit_width *
8);
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n");
printk(KERN_ERR PREFIX
"HARDWARE addr space,NOT supported yet\n");
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@ -325,19 +330,22 @@ static int acpi_read_throttling_status(struct acpi_processor_throttling *throttl
return value;
}
static int acpi_write_throttling_state(struct acpi_processor_throttling *throttling,int value)
static int acpi_write_throttling_state(struct acpi_processor_throttling
*throttling, int value)
{
int ret = -1;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
acpi_os_write_port((acpi_io_address)throttling->control_register.address,
value,
(u32)throttling->control_register.bit_width*8);
acpi_os_write_port((acpi_io_address) throttling->
control_register.address, value,
(u32) throttling->control_register.
bit_width * 8);
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n");
printk(KERN_ERR PREFIX
"HARDWARE addr space,NOT supported yet\n");
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@ -351,7 +359,9 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,int value)
int i;
for (i = 0; i < pr->throttling.state_count; i++) {
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[i]);
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[i]);
if (tx->control == value)
break;
}
@ -364,7 +374,9 @@ static int acpi_get_throttling_value(struct acpi_processor *pr,int state)
{
int value = -1;
if (state >= 0 && state <= pr->throttling.state_count) {
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[state]);
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[state]);
value = tx->control;
}
return value;
@ -375,7 +387,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
int state = 0;
u32 value = 0;
if (!pr)
return -EINVAL;
@ -394,7 +405,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
return 0;
}
static int acpi_processor_get_throttling(struct acpi_processor *pr)
{
return pr->throttling.acpi_processor_get_throttling(pr);
@ -406,7 +416,6 @@ int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, int state)
u32 duty_mask = 0;
u32 duty_value = 0;
if (!pr)
return -EINVAL;
@ -518,7 +527,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
int no_tss = 0;
int no_tsd = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
pr->throttling.address,
@ -534,11 +542,15 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
no_tsd = acpi_processor_get_tsd(pr);
if (no_ptc || no_tss) {
pr->throttling.acpi_processor_get_throttling = &acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling = &acpi_processor_set_throttling_fadt;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling =
&acpi_processor_set_throttling_fadt;
} else {
pr->throttling.acpi_processor_get_throttling = &acpi_processor_get_throttling_ptc;
pr->throttling.acpi_processor_set_throttling = &acpi_processor_set_throttling_ptc;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_ptc;
pr->throttling.acpi_processor_set_throttling =
&acpi_processor_set_throttling_ptc;
}
if (!pr->throttling.address) {
@ -620,7 +632,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
int i = 0;
int result = 0;
if (!pr)
goto end;
@ -655,8 +666,8 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
for (i = 0; i < pr->throttling.state_count; i++)
seq_printf(seq, " %cT%d: %02d%%\n",
(i == pr->throttling.state ? '*' : ' '), i,
(int)pr->throttling.states_tss[i].freqpercentage);
(int)pr->throttling.states_tss[i].
freqpercentage);
end:
return 0;
@ -678,7 +689,6 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
struct acpi_processor *pr = m->private;
char state_string[12] = { '\0' };
if (!pr || (count > sizeof(state_string) - 1))
return -EINVAL;

View File

@ -168,7 +168,8 @@ struct acpi_processor_throttling {
struct acpi_tsd_package domain_info;
cpumask_t shared_cpu_map;
int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
int (*acpi_processor_set_throttling) (struct acpi_processor *pr, int state);
int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
int state);
u32 address;
u8 duty_offset;
@ -207,7 +208,7 @@ struct acpi_processor {
u32 pblk;
int performance_platform_limit;
int throttling_platform_limit;
/*0 - states 0..n-th satte available*/
/* 0 - states 0..n-th state available */
struct acpi_processor_flags flags;
struct acpi_processor_power power;