Commit 64be7eed authored by Venkatesh Pallipadi's avatar Venkatesh Pallipadi Committed by Dave Jones

[CPUFREQ][5/8] acpi-cpufreq: lindent acpi-cpufreq.c

Lindent acpi-cpufreq. Additional changes replacing "return (..)" by "return ..".
No functionality changes in this patch.
Signed-off-by: default avatarDenis Sadykov <denis.m.sadykov@intel.com>
Signed-off-by: default avatarVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: default avatarAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 83d0515b
...@@ -51,7 +51,6 @@ MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); ...@@ -51,7 +51,6 @@ MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
MODULE_DESCRIPTION("ACPI Processor P-States Driver"); MODULE_DESCRIPTION("ACPI Processor P-States Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
enum { enum {
UNDEFINED_CAPABLE = 0, UNDEFINED_CAPABLE = 0,
SYSTEM_INTEL_MSR_CAPABLE, SYSTEM_INTEL_MSR_CAPABLE,
...@@ -74,7 +73,6 @@ static struct cpufreq_driver acpi_cpufreq_driver; ...@@ -74,7 +73,6 @@ static struct cpufreq_driver acpi_cpufreq_driver;
static unsigned int acpi_pstate_strict; static unsigned int acpi_pstate_strict;
static int check_est_cpu(unsigned int cpuid) static int check_est_cpu(unsigned int cpuid)
{ {
struct cpuinfo_x86 *cpu = &cpu_data[cpuid]; struct cpuinfo_x86 *cpu = &cpu_data[cpuid];
...@@ -86,7 +84,6 @@ static int check_est_cpu(unsigned int cpuid) ...@@ -86,7 +84,6 @@ static int check_est_cpu(unsigned int cpuid)
return 1; return 1;
} }
static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
{ {
struct acpi_processor_performance *perf; struct acpi_processor_performance *perf;
...@@ -101,7 +98,6 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) ...@@ -101,7 +98,6 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
return 0; return 0;
} }
static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
{ {
int i; int i;
...@@ -114,7 +110,6 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) ...@@ -114,7 +110,6 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
return data->freq_table[0].frequency; return data->freq_table[0].frequency;
} }
static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data) static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
{ {
switch (data->cpu_feature) { switch (data->cpu_feature) {
...@@ -138,7 +133,7 @@ static void wrport(u16 port, u8 bit_width, u32 value) ...@@ -138,7 +133,7 @@ static void wrport(u16 port, u8 bit_width, u32 value)
} }
} }
static void rdport(u16 port, u8 bit_width, u32 *ret) static void rdport(u16 port, u8 bit_width, u32 * ret)
{ {
*ret = 0; *ret = 0;
if (bit_width <= 8) { if (bit_width <= 8) {
...@@ -268,8 +263,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) ...@@ -268,8 +263,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
dprintk("get_cur_freq_on_cpu (%d)\n", cpu); dprintk("get_cur_freq_on_cpu (%d)\n", cpu);
if (unlikely(data == NULL || if (unlikely(data == NULL ||
data->acpi_data == NULL || data->acpi_data == NULL || data->freq_table == NULL)) {
data->freq_table == NULL)) {
return 0; return 0;
} }
...@@ -295,8 +289,7 @@ static unsigned int check_freqs(cpumask_t mask, unsigned int freq, ...@@ -295,8 +289,7 @@ static unsigned int check_freqs(cpumask_t mask, unsigned int freq,
} }
static int acpi_cpufreq_target(struct cpufreq_policy *policy, static int acpi_cpufreq_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int target_freq, unsigned int relation)
unsigned int relation)
{ {
struct acpi_cpufreq_data *data = drv_data[policy->cpu]; struct acpi_cpufreq_data *data = drv_data[policy->cpu];
struct acpi_processor_performance *perf; struct acpi_processor_performance *perf;
...@@ -312,8 +305,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -312,8 +305,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
if (unlikely(data == NULL || if (unlikely(data == NULL ||
data->acpi_data == NULL || data->acpi_data == NULL || data->freq_table == NULL)) {
data->freq_table == NULL)) {
return -ENODEV; return -ENODEV;
} }
...@@ -321,8 +313,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -321,8 +313,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
result = cpufreq_frequency_table_target(policy, result = cpufreq_frequency_table_target(policy,
data->freq_table, data->freq_table,
target_freq, target_freq,
relation, relation, &next_state);
&next_state);
if (unlikely(result)) if (unlikely(result))
return -ENODEV; return -ENODEV;
...@@ -339,10 +330,12 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -339,10 +330,12 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
next_perf_state = data->freq_table[next_state].index; next_perf_state = data->freq_table[next_state].index;
if (freqs.new == freqs.old) { if (freqs.new == freqs.old) {
if (unlikely(data->resume)) { if (unlikely(data->resume)) {
dprintk("Called after resume, resetting to P%d\n", next_perf_state); dprintk("Called after resume, resetting to P%d\n",
next_perf_state);
data->resume = 0; data->resume = 0;
} else { } else {
dprintk("Already at target state (P%d)\n", next_perf_state); dprintk("Already at target state (P%d)\n",
next_perf_state);
return 0; return 0;
} }
} }
...@@ -351,7 +344,9 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -351,7 +344,9 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
case SYSTEM_INTEL_MSR_CAPABLE: case SYSTEM_INTEL_MSR_CAPABLE:
cmd.type = SYSTEM_INTEL_MSR_CAPABLE; cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
cmd.addr.msr.reg = MSR_IA32_PERF_CTL; cmd.addr.msr.reg = MSR_IA32_PERF_CTL;
msr = (u32) perf->states[next_perf_state].control & INTEL_MSR_RANGE; msr =
(u32) perf->states[next_perf_state].
control & INTEL_MSR_RANGE;
cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr; cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
break; break;
case SYSTEM_IO_CAPABLE: case SYSTEM_IO_CAPABLE:
...@@ -395,10 +390,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -395,10 +390,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
return result; return result;
} }
static int acpi_cpufreq_verify(struct cpufreq_policy *policy)
static int
acpi_cpufreq_verify (
struct cpufreq_policy *policy)
{ {
struct acpi_cpufreq_data *data = drv_data[policy->cpu]; struct acpi_cpufreq_data *data = drv_data[policy->cpu];
...@@ -407,11 +399,8 @@ acpi_cpufreq_verify ( ...@@ -407,11 +399,8 @@ acpi_cpufreq_verify (
return cpufreq_frequency_table_verify(policy, data->freq_table); return cpufreq_frequency_table_verify(policy, data->freq_table);
} }
static unsigned long static unsigned long
acpi_cpufreq_guess_freq ( acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
struct acpi_cpufreq_data *data,
unsigned int cpu)
{ {
struct acpi_processor_performance *perf = data->acpi_data; struct acpi_processor_performance *perf = data->acpi_data;
...@@ -423,14 +412,14 @@ acpi_cpufreq_guess_freq ( ...@@ -423,14 +412,14 @@ acpi_cpufreq_guess_freq (
for (i = 0; i < (perf->state_count - 1); i++) { for (i = 0; i < (perf->state_count - 1); i++) {
freq = freqn; freq = freqn;
freqn = perf->states[i+1].core_frequency * 1000; freqn = perf->states[i + 1].core_frequency * 1000;
if ((2 * cpu_khz) > (freqn + freq)) { if ((2 * cpu_khz) > (freqn + freq)) {
perf->state = i; perf->state = i;
return (freq); return freq;
} }
} }
perf->state = perf->state_count - 1; perf->state = perf->state_count - 1;
return (freqn); return freqn;
} else { } else {
/* assume CPU is at P0... */ /* assume CPU is at P0... */
perf->state = 0; perf->state = 0;
...@@ -438,7 +427,6 @@ acpi_cpufreq_guess_freq ( ...@@ -438,7 +427,6 @@ acpi_cpufreq_guess_freq (
} }
} }
/* /*
* acpi_cpufreq_early_init - initialize ACPI P-States library * acpi_cpufreq_early_init - initialize ACPI P-States library
* *
...@@ -463,7 +451,7 @@ static int acpi_cpufreq_early_init(void) ...@@ -463,7 +451,7 @@ static int acpi_cpufreq_early_init(void)
kfree(acpi_perf_data[j]); kfree(acpi_perf_data[j]);
acpi_perf_data[j] = NULL; acpi_perf_data[j] = NULL;
} }
return (-ENOMEM); return -ENOMEM;
} }
acpi_perf_data[i] = data; acpi_perf_data[i] = data;
cpu_set(i, covered); cpu_set(i, covered);
...@@ -501,9 +489,7 @@ static struct dmi_system_id sw_any_bug_dmi_table[] = { ...@@ -501,9 +489,7 @@ static struct dmi_system_id sw_any_bug_dmi_table[] = {
{ } { }
}; };
static int static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
acpi_cpufreq_cpu_init (
struct cpufreq_policy *policy)
{ {
unsigned int i; unsigned int i;
unsigned int valid_states = 0; unsigned int valid_states = 0;
...@@ -517,11 +503,11 @@ acpi_cpufreq_cpu_init ( ...@@ -517,11 +503,11 @@ acpi_cpufreq_cpu_init (
dprintk("acpi_cpufreq_cpu_init\n"); dprintk("acpi_cpufreq_cpu_init\n");
if (!acpi_perf_data[cpu]) if (!acpi_perf_data[cpu])
return (-ENODEV); return -ENODEV;
data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL); data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL);
if (!data) if (!data)
return (-ENOMEM); return -ENOMEM;
data->acpi_data = acpi_perf_data[cpu]; data->acpi_data = acpi_perf_data[cpu];
drv_data[cpu] = data; drv_data[cpu] = data;
...@@ -585,7 +571,9 @@ acpi_cpufreq_cpu_init ( ...@@ -585,7 +571,9 @@ acpi_cpufreq_cpu_init (
goto err_unreg; goto err_unreg;
} }
data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (perf->state_count + 1), GFP_KERNEL); data->freq_table =
kmalloc(sizeof(struct cpufreq_frequency_table) *
(perf->state_count + 1), GFP_KERNEL);
if (!data->freq_table) { if (!data->freq_table) {
result = -ENOMEM; result = -ENOMEM;
goto err_unreg; goto err_unreg;
...@@ -593,16 +581,17 @@ acpi_cpufreq_cpu_init ( ...@@ -593,16 +581,17 @@ acpi_cpufreq_cpu_init (
/* detect transition latency */ /* detect transition latency */
policy->cpuinfo.transition_latency = 0; policy->cpuinfo.transition_latency = 0;
for (i=0; i<perf->state_count; i++) { for (i = 0; i < perf->state_count; i++) {
if ((perf->states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency) if ((perf->states[i].transition_latency * 1000) >
policy->cpuinfo.transition_latency = perf->states[i].transition_latency * 1000; policy->cpuinfo.transition_latency)
policy->cpuinfo.transition_latency =
perf->states[i].transition_latency * 1000;
} }
policy->governor = CPUFREQ_DEFAULT_GOVERNOR; policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
/* table init */ /* table init */
for (i=0; i<perf->state_count; i++) for (i = 0; i < perf->state_count; i++) {
{ if (i > 0 && perf->states[i].core_frequency ==
if ( i > 0 && perf->states[i].core_frequency ==
perf->states[i - 1].core_frequency) perf->states[i - 1].core_frequency)
continue; continue;
...@@ -636,7 +625,7 @@ acpi_cpufreq_cpu_init ( ...@@ -636,7 +625,7 @@ acpi_cpufreq_cpu_init (
dprintk("CPU%u - ACPI performance management activated.\n", cpu); dprintk("CPU%u - ACPI performance management activated.\n", cpu);
for (i = 0; i < perf->state_count; i++) for (i = 0; i < perf->state_count; i++)
dprintk(" %cP%d: %d MHz, %d mW, %d uS\n", dprintk(" %cP%d: %d MHz, %d mW, %d uS\n",
(i == perf->state?'*':' '), i, (i == perf->state ? '*' : ' '), i,
(u32) perf->states[i].core_frequency, (u32) perf->states[i].core_frequency,
(u32) perf->states[i].power, (u32) perf->states[i].power,
(u32) perf->states[i].transition_latency); (u32) perf->states[i].transition_latency);
...@@ -659,45 +648,38 @@ acpi_cpufreq_cpu_init ( ...@@ -659,45 +648,38 @@ acpi_cpufreq_cpu_init (
kfree(data); kfree(data);
drv_data[cpu] = NULL; drv_data[cpu] = NULL;
return (result); return result;
} }
static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
static int
acpi_cpufreq_cpu_exit (
struct cpufreq_policy *policy)
{ {
struct acpi_cpufreq_data *data = drv_data[policy->cpu]; struct acpi_cpufreq_data *data = drv_data[policy->cpu];
dprintk("acpi_cpufreq_cpu_exit\n"); dprintk("acpi_cpufreq_cpu_exit\n");
if (data) { if (data) {
cpufreq_frequency_table_put_attr(policy->cpu); cpufreq_frequency_table_put_attr(policy->cpu);
drv_data[policy->cpu] = NULL; drv_data[policy->cpu] = NULL;
acpi_processor_unregister_performance(data->acpi_data, policy->cpu); acpi_processor_unregister_performance(data->acpi_data,
policy->cpu);
kfree(data); kfree(data);
} }
return (0); return 0;
} }
static int static int acpi_cpufreq_resume(struct cpufreq_policy *policy)
acpi_cpufreq_resume (
struct cpufreq_policy *policy)
{ {
struct acpi_cpufreq_data *data = drv_data[policy->cpu]; struct acpi_cpufreq_data *data = drv_data[policy->cpu];
dprintk("acpi_cpufreq_resume\n"); dprintk("acpi_cpufreq_resume\n");
data->resume = 1; data->resume = 1;
return (0); return 0;
} }
static struct freq_attr *acpi_cpufreq_attr[] = {
static struct freq_attr* acpi_cpufreq_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
NULL, NULL,
}; };
...@@ -714,9 +696,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { ...@@ -714,9 +696,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = {
.attr = acpi_cpufreq_attr, .attr = acpi_cpufreq_attr,
}; };
static int __init acpi_cpufreq_init(void)
static int __init
acpi_cpufreq_init (void)
{ {
dprintk("acpi_cpufreq_init\n"); dprintk("acpi_cpufreq_init\n");
...@@ -725,9 +705,7 @@ acpi_cpufreq_init (void) ...@@ -725,9 +705,7 @@ acpi_cpufreq_init (void)
return cpufreq_register_driver(&acpi_cpufreq_driver); return cpufreq_register_driver(&acpi_cpufreq_driver);
} }
static void __exit acpi_cpufreq_exit(void)
static void __exit
acpi_cpufreq_exit (void)
{ {
unsigned int i; unsigned int i;
dprintk("acpi_cpufreq_exit\n"); dprintk("acpi_cpufreq_exit\n");
...@@ -742,7 +720,8 @@ acpi_cpufreq_exit (void) ...@@ -742,7 +720,8 @@ acpi_cpufreq_exit (void)
} }
module_param(acpi_pstate_strict, uint, 0644); module_param(acpi_pstate_strict, uint, 0644);
MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes."); MODULE_PARM_DESC(acpi_pstate_strict,
"value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes.");
late_initcall(acpi_cpufreq_init); late_initcall(acpi_cpufreq_init);
module_exit(acpi_cpufreq_exit); module_exit(acpi_cpufreq_exit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment