Commit d4705f43 authored by Aristeu Sergio Rozanski Filho's avatar Aristeu Sergio Rozanski Filho Committed by Arnaldo Carvalho de Melo

o acpi: convert drivers/acpi/processor.c to seq_file

parent dc839f3e
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <asm/delay.h> #include <asm/delay.h>
#include <linux/compatmac.h> #include <linux/compatmac.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "acpi_bus.h" #include "acpi_bus.h"
#include "acpi_drivers.h" #include "acpi_drivers.h"
...@@ -90,6 +91,11 @@ MODULE_LICENSE("GPL"); ...@@ -90,6 +91,11 @@ MODULE_LICENSE("GPL");
static int acpi_processor_add (struct acpi_device *device); static int acpi_processor_add (struct acpi_device *device);
static int acpi_processor_remove (struct acpi_device *device, int type); static int acpi_processor_remove (struct acpi_device *device, int type);
static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_power_open_fs(struct inode *inode, struct file *file);
static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_processor_driver = { static struct acpi_driver acpi_processor_driver = {
.name = ACPI_PROCESSOR_DRIVER_NAME, .name = ACPI_PROCESSOR_DRIVER_NAME,
...@@ -224,6 +230,34 @@ struct acpi_processor_errata { ...@@ -224,6 +230,34 @@ struct acpi_processor_errata {
} piix4; } piix4;
}; };
static struct file_operations acpi_processor_info_fops = {
.open = acpi_processor_info_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_processor_power_fops = {
.open = acpi_processor_power_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_processor_throttling_fops = {
.open = acpi_processor_throttling_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_processor_limit_fops = {
.open = acpi_processor_limit_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct acpi_processor *processors[NR_CPUS]; static struct acpi_processor *processors[NR_CPUS];
static struct acpi_processor_errata errata; static struct acpi_processor_errata errata;
static void (*pm_idle_save)(void) = NULL; static void (*pm_idle_save)(void) = NULL;
...@@ -231,6 +265,13 @@ static void (*pm_idle_save)(void) = NULL; ...@@ -231,6 +265,13 @@ static void (*pm_idle_save)(void) = NULL;
#ifdef CONFIG_ACPI_PROCESSOR_PERF #ifdef CONFIG_ACPI_PROCESSOR_PERF
static unsigned int cpufreq_usage_count = 0; static unsigned int cpufreq_usage_count = 0;
static struct cpufreq_driver *acpi_cpufreq_driver; static struct cpufreq_driver *acpi_cpufreq_driver;
static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_processor_perf_fops = {
.open = acpi_processor_perf_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif
...@@ -1884,174 +1925,132 @@ acpi_cpufreq_exit ( ...@@ -1884,174 +1925,132 @@ acpi_cpufreq_exit (
struct proc_dir_entry *acpi_processor_dir = NULL; struct proc_dir_entry *acpi_processor_dir = NULL;
static int static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
acpi_processor_read_info (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *) data; struct acpi_processor *pr = (struct acpi_processor *)seq->private;
char *p = page;
int len = 0;
ACPI_FUNCTION_TRACE("acpi_processor_read_info"); ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
if (!pr || (off != 0)) if (!pr)
goto end; goto end;
p += sprintf(p, "processor id: %d\n", seq_printf(seq, "processor id: %d\n"
pr->id); "acpi id: %d\n"
"bus mastering control: %s\n"
p += sprintf(p, "acpi id: %d\n", "power management: %s\n"
pr->acpi_id); "throttling control: %s\n"
"performance management: %s\n"
p += sprintf(p, "bus mastering control: %s\n", "limit interface: %s\n",
pr->flags.bm_control ? "yes" : "no"); pr->id,
pr->acpi_id,
p += sprintf(p, "power management: %s\n", pr->flags.bm_control ? "yes" : "no",
pr->flags.power ? "yes" : "no"); pr->flags.power ? "yes" : "no",
pr->flags.throttling ? "yes" : "no",
p += sprintf(p, "throttling control: %s\n", pr->flags.performance ? "yes" : "no",
pr->flags.throttling ? "yes" : "no"); pr->flags.limit ? "yes" : "no");
p += sprintf(p, "performance management: %s\n",
pr->flags.performance ? "yes" : "no");
p += sprintf(p, "limit interface: %s\n",
pr->flags.limit ? "yes" : "no");
end: end:
len = (p - page); return 0;
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
} }
static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_processor_info_seq_show,
PDE(inode)->data);
}
static int static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
acpi_processor_read_power (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *) data; struct acpi_processor *pr = (struct acpi_processor *)seq->private;
char *p = page;
int len = 0;
int i = 0; int i = 0;
ACPI_FUNCTION_TRACE("acpi_processor_read_power"); ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
if (!pr || (off != 0)) if (!pr)
goto end; goto end;
p += sprintf(p, "active state: C%d\n", seq_printf(seq, "active state: C%d\n"
pr->power.state); "default state: C%d\n"
"bus master activity: %08x\n"
p += sprintf(p, "default state: C%d\n", pr->power.state,
pr->power.default_state); pr->power.default_state,
pr->power.bm_activity);
p += sprintf(p, "bus master activity: %08x\n", seq_puts(seq, "states:\n");
pr->power.bm_activity);
p += sprintf(p, "states:\n"); for (i = 1; i < ACPI_C_STATE_COUNT; i++) {
seq_printf(seq, " %cC%d: ",
for (i=1; i<ACPI_C_STATE_COUNT; i++) {
p += sprintf(p, " %cC%d: ",
(i == pr->power.state?'*':' '), i); (i == pr->power.state?'*':' '), i);
if (!pr->power.states[i].valid) { if (!pr->power.states[i].valid) {
p += sprintf(p, "<not supported>\n"); seq_puts(seq, "<not supported>\n");
continue; continue;
} }
if (pr->power.states[i].promotion.state) if (pr->power.states[i].promotion.state)
p += sprintf(p, "promotion[C%d] ", seq_printf(seq, "promotion[C%d] ",
pr->power.states[i].promotion.state); pr->power.states[i].promotion.state);
else else
p += sprintf(p, "promotion[--] "); seq_puts(seq, "promotion[--] ");
if (pr->power.states[i].demotion.state) if (pr->power.states[i].demotion.state)
p += sprintf(p, "demotion[C%d] ", seq_printf(seq, "demotion[C%d] ",
pr->power.states[i].demotion.state); pr->power.states[i].demotion.state);
else else
p += sprintf(p, "demotion[--] "); seq_puts(seq, "demotion[--] ");
p += sprintf(p, "latency[%03d] usage[%08d]\n", seq_printf(seq, "latency[%03d] usage[%08d]\n",
pr->power.states[i].latency, pr->power.states[i].latency,
pr->power.states[i].usage); pr->power.states[i].usage);
} }
end: end:
len = (p - page); return 0;
if (len <= off+count) *eof = 1; }
*start = page + off;
len -= off; static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
if (len>count) len = count; {
if (len<0) len = 0; return single_open(file, acpi_processor_power_seq_show,
PDE(inode)->data);
return_VALUE(len);
} }
#ifdef CONFIG_ACPI_PROCESSOR_PERF #ifdef CONFIG_ACPI_PROCESSOR_PERF
static int static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
acpi_processor_read_performance (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *) data; struct acpi_processor *pr = (struct acpi_processor *)seq->private;
char *p = page;
int len = 0;
int i = 0; int i = 0;
ACPI_FUNCTION_TRACE("acpi_processor_read_performance"); ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
if (!pr || (off != 0)) if (!pr)
goto end; goto end;
if (!pr->flags.performance) { if (!pr->flags.performance) {
p += sprintf(p, "<not supported>\n"); seq_puts(seq, "<not supported>\n");
goto end; goto end;
} }
p += sprintf(p, "state count: %d\n", seq_printf(seq, "state count: %d\n"
pr->performance.state_count); "active state: P%d\n",
pr->performance.state_count,
p += sprintf(p, "active state: P%d\n", pr->performance.state);
pr->performance.state);
p += sprintf(p, "states:\n");
for (i=0; i<pr->performance.state_count; i++) seq_puts(seq, "states:\n");
p += sprintf(p, " %cP%d: %d MHz, %d mW, %d uS\n", for (i = 0; i < pr->performance.state_count; i++)
seq_printf(seq, " %cP%d: %d MHz, %d mW, %d uS\n",
(i == pr->performance.state?'*':' '), i, (i == pr->performance.state?'*':' '), i,
(u32) pr->performance.states[i].core_frequency, (u32) pr->performance.states[i].core_frequency,
(u32) pr->performance.states[i].power, (u32) pr->performance.states[i].power,
(u32) pr->performance.states[i].transition_latency); (u32) pr->performance.states[i].transition_latency);
end: end:
len = (p - page); return 0;
if (len <= off+count) *eof = 1; }
*start = page + off;
len -= off; static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
if (len>count) len = count; {
if (len<0) len = 0; return single_open(file, acpi_processor_perf_seq_show,
PDE(inode)->data);
return_VALUE(len);
} }
static int static int
...@@ -2091,63 +2090,49 @@ acpi_processor_write_performance ( ...@@ -2091,63 +2090,49 @@ acpi_processor_write_performance (
} }
#endif #endif
static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset)
static int
acpi_processor_read_throttling (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *) data; struct acpi_processor *pr = (struct acpi_processor *)seq->private;
char *p = page;
int len = 0;
int i = 0; int i = 0;
int result = 0; int result = 0;
ACPI_FUNCTION_TRACE("acpi_processor_read_throttling"); ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
if (!pr || (off != 0)) if (!pr)
goto end; goto end;
if (!(pr->throttling.state_count > 0)) { if (!(pr->throttling.state_count > 0)) {
p += sprintf(p, "<not supported>\n"); seq_puts(seq, "<not supported>\n");
goto end; goto end;
} }
result = acpi_processor_get_throttling(pr); result = acpi_processor_get_throttling(pr);
if (result) { if (result) {
p += sprintf(p, "Could not determine current throttling state.\n"); seq_puts(seq, "Could not determine current throttling state.\n");
goto end; goto end;
} }
p += sprintf(p, "state count: %d\n", seq_printf(seq, "state count: %d\n"
pr->throttling.state_count); "active state: T%d\n",
pr->throttling.state_count,
p += sprintf(p, "active state: T%d\n", pr->throttling.state);
pr->throttling.state);
p += sprintf(p, "states:\n"); seq_puts(seq, "states:\n");
for (i = 0; i < pr->throttling.state_count; i++)
for (i=0; i<pr->throttling.state_count; i++) seq_printf(seq, " %cT%d: %02d%%\n",
p += sprintf(p, " %cT%d: %02d%%\n",
(i == pr->throttling.state?'*':' '), i, (i == pr->throttling.state?'*':' '), i,
(pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0)); (pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0));
end: end:
len = (p - page); return 0;
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
} }
static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_processor_throttling_seq_show,
PDE(inode)->data);
}
static int static int
acpi_processor_write_throttling ( acpi_processor_write_throttling (
...@@ -2178,53 +2163,38 @@ acpi_processor_write_throttling ( ...@@ -2178,53 +2163,38 @@ acpi_processor_write_throttling (
return_VALUE(count); return_VALUE(count);
} }
static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
static int
acpi_processor_read_limit (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_processor *pr = (struct acpi_processor *) data; struct acpi_processor *pr = (struct acpi_processor *)seq->private;
char *p = page;
int len = 0;
ACPI_FUNCTION_TRACE("acpi_processor_read_limit"); ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
if (!pr || (off != 0)) if (!pr)
goto end; goto end;
if (!pr->flags.limit) { if (!pr->flags.limit) {
p += sprintf(p, "<not supported>\n"); seq_puts(seq, "<not supported>\n");
goto end; goto end;
} }
p += sprintf(p, "active limit: P%d:T%d\n", seq_printf(seq, "active limit: P%d:T%d\n"
pr->limit.state.px, pr->limit.state.tx); "platform limit: P%d:T0\n"
"user limit: P%d:T%d\n"
p += sprintf(p, "platform limit: P%d:T0\n", "thermal limit: P%d:T%d\n",
pr->flags.performance?pr->performance.platform_limit:0); pr->limit.state.px, pr->limit.state.tx,
pr->flags.performance?pr->performance.platform_limit:0,
p += sprintf(p, "user limit: P%d:T%d\n", pr->limit.user.px, pr->limit.user.tx,
pr->limit.user.px, pr->limit.user.tx); pr->limit.thermal.px, pr->limit.thermal.tx);
p += sprintf(p, "thermal limit: P%d:T%d\n",
pr->limit.thermal.px, pr->limit.thermal.tx);
end: end:
len = (p - page); return 0;
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
} }
static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_processor_limit_seq_show,
PDE(inode)->data);
}
static int static int
acpi_processor_write_limit ( acpi_processor_write_limit (
...@@ -2304,7 +2274,7 @@ acpi_processor_add_fs ( ...@@ -2304,7 +2274,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_INFO)); ACPI_PROCESSOR_FILE_INFO));
else { else {
entry->read_proc = acpi_processor_read_info; entry->proc_fops = &acpi_processor_info_fops;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
...@@ -2316,7 +2286,7 @@ acpi_processor_add_fs ( ...@@ -2316,7 +2286,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_POWER)); ACPI_PROCESSOR_FILE_POWER));
else { else {
entry->read_proc = acpi_processor_read_power; entry->proc_fops = &acpi_processor_power_fops;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
...@@ -2329,7 +2299,7 @@ acpi_processor_add_fs ( ...@@ -2329,7 +2299,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_PERFORMANCE)); ACPI_PROCESSOR_FILE_PERFORMANCE));
else { else {
entry->read_proc = acpi_processor_read_performance; entry->proc_fops = &acpi_processor_perf_fops;
entry->write_proc = acpi_processor_write_performance; entry->write_proc = acpi_processor_write_performance;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
...@@ -2343,7 +2313,7 @@ acpi_processor_add_fs ( ...@@ -2343,7 +2313,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_THROTTLING)); ACPI_PROCESSOR_FILE_THROTTLING));
else { else {
entry->read_proc = acpi_processor_read_throttling; entry->proc_fops = &acpi_processor_throttling_fops;
entry->write_proc = acpi_processor_write_throttling; entry->write_proc = acpi_processor_write_throttling;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
...@@ -2356,7 +2326,7 @@ acpi_processor_add_fs ( ...@@ -2356,7 +2326,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_LIMIT)); ACPI_PROCESSOR_FILE_LIMIT));
else { else {
entry->read_proc = acpi_processor_read_limit; entry->proc_fops = &acpi_processor_limit_fops;
entry->write_proc = acpi_processor_write_limit; entry->write_proc = acpi_processor_write_limit;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
......
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