Commit 61bc79b5 authored by Andy Grover's avatar Andy Grover

Merge http://groveronline.com:5555

into groveronline.com:/root/bk/linux-acpi
parents 5dfef799 564a39dd
......@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"
......@@ -53,6 +54,7 @@ MODULE_LICENSE("GPL");
int acpi_ac_add (struct acpi_device *device);
int acpi_ac_remove (struct acpi_device *device, int type);
static int acpi_ac_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_ac_driver = {
.name = ACPI_AC_DRIVER_NAME,
......@@ -69,6 +71,12 @@ struct acpi_ac {
unsigned long state;
};
static struct file_operations acpi_ac_fops = {
.open = acpi_ac_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
AC Adapter Management
......@@ -103,53 +111,40 @@ acpi_ac_get_state (
struct proc_dir_entry *acpi_ac_dir = NULL;
static int
acpi_ac_read_state (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
int acpi_ac_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_ac *ac = (struct acpi_ac *) data;
char *p = page;
int len = 0;
struct acpi_ac *ac = (struct acpi_ac *) seq->private;
ACPI_FUNCTION_TRACE("acpi_ac_read_state");
ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
if (!ac || (off != 0))
goto end;
if (!ac)
return 0;
if (acpi_ac_get_state(ac)) {
p += sprintf(p, "ERROR: Unable to read AC Adapter state\n");
goto end;
seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
return 0;
}
p += sprintf(p, "state: ");
seq_puts(seq, "state: ");
switch (ac->state) {
case ACPI_AC_STATUS_OFFLINE:
p += sprintf(p, "off-line\n");
seq_puts(seq, "off-line\n");
break;
case ACPI_AC_STATUS_ONLINE:
p += sprintf(p, "on-line\n");
seq_puts(seq, "on-line\n");
break;
default:
p += sprintf(p, "unknown\n");
seq_puts(seq, "unknown\n");
break;
}
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_ac_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
}
static int
acpi_ac_add_fs (
......@@ -174,7 +169,7 @@ acpi_ac_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_AC_FILE_STATE));
else {
entry->read_proc = acpi_ac_read_state;
entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device);
}
......
......@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"
......@@ -69,6 +70,7 @@ MODULE_LICENSE("GPL");
int acpi_button_add (struct acpi_device *device);
int acpi_button_remove (struct acpi_device *device, int type);
static int acpi_button_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_button_driver = {
.name = ACPI_BUTTON_DRIVER_NAME,
......@@ -87,6 +89,12 @@ struct acpi_button {
unsigned long pushed;
};
static struct file_operations acpi_button_fops = {
.open = acpi_button_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
FS Interface (/proc)
......@@ -94,39 +102,26 @@ struct acpi_button {
static struct proc_dir_entry *acpi_button_dir = NULL;
static int
acpi_button_read_info (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_button_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_button *button = (struct acpi_button *) data;
char *p = page;
int len = 0;
struct acpi_button *button = (struct acpi_button *) seq->private;
ACPI_FUNCTION_TRACE("acpi_button_read_info");
ACPI_FUNCTION_TRACE("acpi_button_seq_show");
if (!button || !button->device)
goto end;
return 0;
p += sprintf(p, "type: %s\n",
seq_printf(seq, "type: %s\n",
acpi_device_name(button->device));
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_button_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_button_seq_show, PDE(inode)->data);
}
static int
acpi_button_add_fs (
struct acpi_device *device)
......@@ -170,7 +165,7 @@ acpi_button_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO));
else {
entry->read_proc = acpi_button_read_info;
entry->proc_fops = &acpi_button_fops;
entry->data = acpi_driver_data(device);
}
......
......@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"
......@@ -48,6 +49,7 @@ ACPI_MODULE_NAME ("acpi_power")
int acpi_power_add (struct acpi_device *device);
int acpi_power_remove (struct acpi_device *device, int type);
static int acpi_power_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_power_driver = {
.name = ACPI_POWER_DRIVER_NAME,
......@@ -71,6 +73,12 @@ struct acpi_power_resource
static struct list_head acpi_power_resource_list;
static struct file_operations acpi_power_fops = {
.open = acpi_power_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
Power Resource Management
......@@ -379,58 +387,45 @@ acpi_power_transition (
struct proc_dir_entry *acpi_power_dir = NULL;
static int
acpi_power_read_status (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_power_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_power_resource *resource = NULL;
char *p = page;
int len;
ACPI_FUNCTION_TRACE("acpi_power_read_status");
ACPI_FUNCTION_TRACE("acpi_power_seq_show");
if (!data || (off != 0))
goto end;
resource = (struct acpi_power_resource *)seq->private;
resource = (struct acpi_power_resource *) data;
if (!resource)
goto end;
p += sprintf(p, "state: ");
seq_puts(seq, "state: ");
switch (resource->state) {
case ACPI_POWER_RESOURCE_STATE_ON:
p += sprintf(p, "on\n");
seq_puts(seq, "on\n");
break;
case ACPI_POWER_RESOURCE_STATE_OFF:
p += sprintf(p, "off\n");
seq_puts(seq, "off\n");
break;
default:
p += sprintf(p, "unknown\n");
seq_puts(seq, "unknown\n");
break;
}
p += sprintf(p, "system level: S%d\n",
resource->system_level);
p += sprintf(p, "order: %d\n",
resource->order);
p += sprintf(p, "reference count: %d\n",
resource->references);
seq_printf(seq, "system level: S%d\n"
"order: %d\n"
"reference count: %d\n",
resource->system_level,
resource->order,
resource->references);
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_power_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_power_seq_show, PDE(inode)->data);
}
static int
acpi_power_add_fs (
......@@ -458,7 +453,7 @@ acpi_power_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_POWER_FILE_STATUS));
else {
entry->read_proc = acpi_power_read_status;
entry->proc_fops = &acpi_power_fops;
entry->data = acpi_driver_data(device);
}
......
......@@ -40,6 +40,7 @@
#include <asm/delay.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"
......@@ -90,6 +91,11 @@ MODULE_LICENSE("GPL");
static int acpi_processor_add (struct acpi_device *device);
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 = {
.name = ACPI_PROCESSOR_DRIVER_NAME,
......@@ -224,6 +230,34 @@ struct acpi_processor_errata {
} 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_errata errata;
static void (*pm_idle_save)(void) = NULL;
......@@ -231,6 +265,13 @@ static void (*pm_idle_save)(void) = NULL;
#ifdef CONFIG_ACPI_PROCESSOR_PERF
static unsigned int cpufreq_usage_count = 0;
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
......@@ -1884,174 +1925,132 @@ acpi_cpufreq_exit (
struct proc_dir_entry *acpi_processor_dir = NULL;
static int
acpi_processor_read_info (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_processor *pr = (struct acpi_processor *) data;
char *p = page;
int len = 0;
struct acpi_processor *pr = (struct acpi_processor *)seq->private;
ACPI_FUNCTION_TRACE("acpi_processor_read_info");
ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
if (!pr || (off != 0))
if (!pr)
goto end;
p += sprintf(p, "processor id: %d\n",
pr->id);
p += sprintf(p, "acpi id: %d\n",
pr->acpi_id);
p += sprintf(p, "bus mastering control: %s\n",
pr->flags.bm_control ? "yes" : "no");
p += sprintf(p, "power management: %s\n",
pr->flags.power ? "yes" : "no");
p += sprintf(p, "throttling control: %s\n",
pr->flags.throttling ? "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");
seq_printf(seq, "processor id: %d\n"
"acpi id: %d\n"
"bus mastering control: %s\n"
"power management: %s\n"
"throttling control: %s\n"
"performance management: %s\n"
"limit interface: %s\n",
pr->id,
pr->acpi_id,
pr->flags.bm_control ? "yes" : "no",
pr->flags.power ? "yes" : "no",
pr->flags.throttling ? "yes" : "no",
pr->flags.performance ? "yes" : "no",
pr->flags.limit ? "yes" : "no");
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
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
acpi_processor_read_power (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_processor *pr = (struct acpi_processor *) data;
char *p = page;
int len = 0;
struct acpi_processor *pr = (struct acpi_processor *)seq->private;
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;
p += sprintf(p, "active state: C%d\n",
pr->power.state);
p += sprintf(p, "default state: C%d\n",
pr->power.default_state);
seq_printf(seq, "active state: C%d\n"
"default state: C%d\n"
"bus master activity: %08x\n",
pr->power.state,
pr->power.default_state,
pr->power.bm_activity);
p += sprintf(p, "bus master activity: %08x\n",
pr->power.bm_activity);
seq_puts(seq, "states:\n");
p += sprintf(p, "states:\n");
for (i=1; i<ACPI_C_STATE_COUNT; i++) {
p += sprintf(p, " %cC%d: ",
for (i = 1; i < ACPI_C_STATE_COUNT; i++) {
seq_printf(seq, " %cC%d: ",
(i == pr->power.state?'*':' '), i);
if (!pr->power.states[i].valid) {
p += sprintf(p, "<not supported>\n");
seq_puts(seq, "<not supported>\n");
continue;
}
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);
else
p += sprintf(p, "promotion[--] ");
seq_puts(seq, "promotion[--] ");
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);
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].usage);
}
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_processor_power_seq_show,
PDE(inode)->data);
}
#ifdef CONFIG_ACPI_PROCESSOR_PERF
static int
acpi_processor_read_performance (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_processor *pr = (struct acpi_processor *) data;
char *p = page;
int len = 0;
struct acpi_processor *pr = (struct acpi_processor *)seq->private;
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;
if (!pr->flags.performance) {
p += sprintf(p, "<not supported>\n");
seq_puts(seq, "<not supported>\n");
goto end;
}
p += sprintf(p, "state count: %d\n",
pr->performance.state_count);
p += sprintf(p, "active state: P%d\n",
pr->performance.state);
p += sprintf(p, "states:\n");
seq_printf(seq, "state count: %d\n"
"active state: P%d\n",
pr->performance.state_count,
pr->performance.state);
for (i=0; i<pr->performance.state_count; i++)
p += sprintf(p, " %cP%d: %d MHz, %d mW, %d uS\n",
seq_puts(seq, "states:\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,
(u32) pr->performance.states[i].core_frequency,
(u32) pr->performance.states[i].power,
(u32) pr->performance.states[i].transition_latency);
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_processor_perf_seq_show,
PDE(inode)->data);
}
static int
......@@ -2091,63 +2090,49 @@ acpi_processor_write_performance (
}
#endif
static int
acpi_processor_read_throttling (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_processor *pr = (struct acpi_processor *) data;
char *p = page;
int len = 0;
struct acpi_processor *pr = (struct acpi_processor *)seq->private;
int i = 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;
if (!(pr->throttling.state_count > 0)) {
p += sprintf(p, "<not supported>\n");
seq_puts(seq, "<not supported>\n");
goto end;
}
result = acpi_processor_get_throttling(pr);
if (result) {
p += sprintf(p, "Could not determine current throttling state.\n");
seq_puts(seq, "Could not determine current throttling state.\n");
goto end;
}
p += sprintf(p, "state count: %d\n",
pr->throttling.state_count);
p += sprintf(p, "active state: T%d\n",
pr->throttling.state);
seq_printf(seq, "state count: %d\n"
"active state: T%d\n",
pr->throttling.state_count,
pr->throttling.state);
p += sprintf(p, "states:\n");
for (i=0; i<pr->throttling.state_count; i++)
p += sprintf(p, " %cT%d: %02d%%\n",
seq_puts(seq, "states:\n");
for (i = 0; i < pr->throttling.state_count; i++)
seq_printf(seq, " %cT%d: %02d%%\n",
(i == pr->throttling.state?'*':' '), i,
(pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0));
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
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
acpi_processor_write_throttling (
......@@ -2178,53 +2163,38 @@ acpi_processor_write_throttling (
return_VALUE(count);
}
static int
acpi_processor_read_limit (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_processor *pr = (struct acpi_processor *) data;
char *p = page;
int len = 0;
struct acpi_processor *pr = (struct acpi_processor *)seq->private;
ACPI_FUNCTION_TRACE("acpi_processor_read_limit");
ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
if (!pr || (off != 0))
if (!pr)
goto end;
if (!pr->flags.limit) {
p += sprintf(p, "<not supported>\n");
seq_puts(seq, "<not supported>\n");
goto end;
}
p += sprintf(p, "active limit: P%d:T%d\n",
pr->limit.state.px, pr->limit.state.tx);
p += sprintf(p, "platform limit: P%d:T0\n",
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);
p += sprintf(p, "thermal limit: P%d:T%d\n",
pr->limit.thermal.px, pr->limit.thermal.tx);
seq_printf(seq, "active limit: P%d:T%d\n"
"platform limit: P%d:T0\n"
"user limit: P%d:T%d\n"
"thermal limit: P%d:T%d\n",
pr->limit.state.px, pr->limit.state.tx,
pr->flags.performance?pr->performance.platform_limit:0,
pr->limit.user.px, pr->limit.user.tx,
pr->limit.thermal.px, pr->limit.thermal.tx);
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
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
acpi_processor_write_limit (
......@@ -2304,7 +2274,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_INFO));
else {
entry->read_proc = acpi_processor_read_info;
entry->proc_fops = &acpi_processor_info_fops;
entry->data = acpi_driver_data(device);
}
......@@ -2316,7 +2286,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_POWER));
else {
entry->read_proc = acpi_processor_read_power;
entry->proc_fops = &acpi_processor_power_fops;
entry->data = acpi_driver_data(device);
}
......@@ -2329,7 +2299,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_PERFORMANCE));
else {
entry->read_proc = acpi_processor_read_performance;
entry->proc_fops = &acpi_processor_perf_fops;
entry->write_proc = acpi_processor_write_performance;
entry->data = acpi_driver_data(device);
}
......@@ -2343,7 +2313,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_THROTTLING));
else {
entry->read_proc = acpi_processor_read_throttling;
entry->proc_fops = &acpi_processor_throttling_fops;
entry->write_proc = acpi_processor_write_throttling;
entry->data = acpi_driver_data(device);
}
......@@ -2356,7 +2326,7 @@ acpi_processor_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_PROCESSOR_FILE_LIMIT));
else {
entry->read_proc = acpi_processor_read_limit;
entry->proc_fops = &acpi_processor_limit_fops;
entry->write_proc = acpi_processor_write_limit;
entry->data = acpi_driver_data(device);
}
......
......@@ -15,6 +15,7 @@
#include <linux/pm.h>
#include <linux/device.h>
#include <linux/suspend.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/acpi.h>
......@@ -32,8 +33,25 @@ ACPI_MODULE_NAME ("sleep")
#define ACPI_SYSTEM_FILE_SLEEP "sleep"
#define ACPI_SYSTEM_FILE_ALARM "alarm"
static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file);
static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file);
static u8 sleep_states[ACPI_S_STATE_COUNT];
static struct file_operations acpi_system_sleep_fops = {
.open = acpi_system_sleep_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_system_alarm_fops = {
.open = acpi_system_alarm_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void
acpi_power_off (void)
{
......@@ -271,43 +289,26 @@ acpi_suspend (
return status;
}
static int
acpi_system_read_sleep (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
{
char *p = page;
int size;
int i;
ACPI_FUNCTION_TRACE("acpi_system_read_sleep");
if (off != 0)
goto end;
ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
for (i = 0; i <= ACPI_STATE_S5; i++) {
if (sleep_states[i])
p += sprintf(p,"S%d ", i);
seq_printf(seq,"S%d ", i);
}
p += sprintf(p, "\n");
seq_puts(seq, "\n");
end:
size = (p - page);
if (size <= off+count) *eof = 1;
*start = page + off;
size -= off;
if (size>count) size = count;
if (size<0) size = 0;
return_VALUE(size);
return 0;
}
static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_system_sleep_seq_show, PDE(inode)->data);
}
static int
acpi_system_write_sleep (
......@@ -349,25 +350,12 @@ acpi_system_write_sleep (
return_VALUE(count);
}
static int
acpi_system_read_alarm (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *context)
static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
{
char *p = page;
int size = 0;
u32 sec, min, hr;
u32 day, mo, yr;
ACPI_FUNCTION_TRACE("acpi_system_read_alarm");
if (off != 0)
goto end;
ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
spin_lock(&rtc_lock);
......@@ -427,21 +415,19 @@ acpi_system_read_alarm (
yr += 2000;
#endif
p += sprintf(p,"%4.4u-", yr);
p += (mo > 12) ? sprintf(p, "**-") : sprintf(p, "%2.2u-", mo);
p += (day > 31) ? sprintf(p, "** ") : sprintf(p, "%2.2u ", day);
p += (hr > 23) ? sprintf(p, "**:") : sprintf(p, "%2.2u:", hr);
p += (min > 59) ? sprintf(p, "**:") : sprintf(p, "%2.2u:", min);
p += (sec > 59) ? sprintf(p, "**\n") : sprintf(p, "%2.2u\n", sec);
end:
size = p - page;
if (size < count) *eof = 1;
else if (size > count) size = count;
if (size < 0) size = 0;
*start = page;
return_VALUE(size);
seq_printf(seq,"%4.4u-", yr);
(mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
(day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
(hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
(min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
(sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
return 0;
}
static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
}
......@@ -687,7 +673,7 @@ static int __init acpi_sleep_init(void)
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_SLEEP));
else {
entry->read_proc = acpi_system_read_sleep;
entry->proc_fops = &acpi_system_sleep_fops;
entry->write_proc = acpi_system_write_sleep;
}
......@@ -699,7 +685,7 @@ static int __init acpi_sleep_init(void)
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_ALARM));
else {
entry->read_proc = acpi_system_read_alarm;
entry->proc_fops = &acpi_system_alarm_fops;
entry->write_proc = acpi_system_write_alarm;
}
......
......@@ -39,6 +39,7 @@
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/kmod.h>
#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"
......@@ -79,6 +80,11 @@ MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
static int acpi_thermal_add (struct acpi_device *device);
static int acpi_thermal_remove (struct acpi_device *device, int type);
static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_thermal_driver = {
.name = ACPI_THERMAL_DRIVER_NAME,
......@@ -157,6 +163,40 @@ struct acpi_thermal {
struct timer_list timer;
};
static struct file_operations acpi_thermal_state_fops = {
.open = acpi_thermal_state_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_thermal_temp_fops = {
.open = acpi_thermal_temp_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_thermal_trip_fops = {
.open = acpi_thermal_trip_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_thermal_cooling_fops = {
.open = acpi_thermal_cooling_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations acpi_thermal_polling_fops = {
.open = acpi_thermal_polling_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* --------------------------------------------------------------------------
Thermal Zone Management
......@@ -720,154 +760,119 @@ acpi_thermal_check (
struct proc_dir_entry *acpi_thermal_dir = NULL;
static int
acpi_thermal_read_state (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_thermal *tz = (struct acpi_thermal *) data;
char *p = page;
int len = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
ACPI_FUNCTION_TRACE("acpi_thermal_read_state");
ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
if (!tz || (off != 0))
if (!tz)
goto end;
p += sprintf(p, "state: ");
seq_puts(seq, "state: ");
if (!tz->state.critical && !tz->state.hot && !tz->state.passive && !tz->state.active)
p += sprintf(p, "ok\n");
seq_puts(seq, "ok\n");
else {
if (tz->state.critical)
p += sprintf(p, "critical ");
seq_puts(seq, "critical ");
if (tz->state.hot)
p += sprintf(p, "hot ");
seq_puts(seq, "hot ");
if (tz->state.passive)
p += sprintf(p, "passive ");
seq_puts(seq, "passive ");
if (tz->state.active)
p += sprintf(p, "active[%d]", tz->state.active_index);
p += sprintf(p, "\n");
seq_printf(seq, "active[%d]", tz->state.active_index);
seq_puts(seq, "\n");
}
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
}
static int
acpi_thermal_read_temperature (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
{
int result = 0;
struct acpi_thermal *tz = (struct acpi_thermal *) data;
char *p = page;
int len = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
ACPI_FUNCTION_TRACE("acpi_thermal_read_temperature");
ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
if (!tz || (off != 0))
if (!tz)
goto end;
result = acpi_thermal_get_temperature(tz);
if (result)
goto end;
p += sprintf(p, "temperature: %ld C\n",
seq_printf(seq, "temperature: %ld C\n",
KELVIN_TO_CELSIUS(tz->temperature));
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
}
static int
acpi_thermal_read_trip_points (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_thermal *tz = (struct acpi_thermal *) data;
char *p = page;
int len = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
int i = 0;
int j = 0;
ACPI_FUNCTION_TRACE("acpi_thermal_read_trip_points");
ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
if (!tz || (off != 0))
if (!tz)
goto end;
if (tz->trips.critical.flags.valid)
p += sprintf(p, "critical (S5): %ld C\n",
seq_printf(seq, "critical (S5): %ld C\n",
KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
if (tz->trips.hot.flags.valid)
p += sprintf(p, "hot (S4): %ld C\n",
seq_printf(seq, "hot (S4): %ld C\n",
KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
if (tz->trips.passive.flags.valid) {
p += sprintf(p, "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
seq_printf(seq, "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
tz->trips.passive.tc1,
tz->trips.passive.tc2,
tz->trips.passive.tsp);
for (j=0; j<tz->trips.passive.devices.count; j++) {
p += sprintf(p, "0x%p ", tz->trips.passive.devices.handles[j]);
seq_printf(seq, "0x%p ", tz->trips.passive.devices.handles[j]);
}
p += sprintf(p, "\n");
seq_puts(seq, "\n");
}
for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (!(tz->trips.active[i].flags.valid))
break;
p += sprintf(p, "active[%d]: %ld C: devices=",
seq_printf(seq, "active[%d]: %ld C: devices=",
i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
for (j=0; j<tz->trips.active[i].devices.count; j++)
p += sprintf(p, "0x%p ",
for (j = 0; j < tz->trips.active[i].devices.count; j++)
seq_printf(seq, "0x%p ",
tz->trips.active[i].devices.handles[j]);
p += sprintf(p, "\n");
seq_puts(seq, "\n");
}
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
}
static int
acpi_thermal_write_trip_points (
......@@ -909,43 +914,32 @@ acpi_thermal_write_trip_points (
}
static int
acpi_thermal_read_cooling_mode (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_thermal *tz = (struct acpi_thermal *) data;
char *p = page;
int len = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
ACPI_FUNCTION_TRACE("acpi_thermal_read_cooling_mode");
ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
if (!tz || (off != 0))
if (!tz)
goto end;
if (!tz->flags.cooling_mode) {
p += sprintf(p, "<not supported>\n");
seq_puts(seq, "<not supported>\n");
goto end;
}
p += sprintf(p, "cooling mode: %s\n",
seq_printf(seq, "cooling mode: %s\n",
tz->cooling_mode?"passive":"active");
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_thermal_cooling_seq_show,
PDE(inode)->data);
}
static int
acpi_thermal_write_cooling_mode (
......@@ -980,43 +974,32 @@ acpi_thermal_write_cooling_mode (
}
static int
acpi_thermal_read_polling (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
{
struct acpi_thermal *tz = (struct acpi_thermal *) data;
char *p = page;
int len = 0;
struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
ACPI_FUNCTION_TRACE("acpi_thermal_read_polling");
ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
if (!tz || (off != 0))
if (!tz)
goto end;
if (!tz->polling_frequency) {
p += sprintf(p, "<polling disabled>\n");
seq_puts(seq, "<polling disabled>\n");
goto end;
}
p += sprintf(p, "polling frequency: %lu seconds\n",
seq_printf(seq, "polling frequency: %lu seconds\n",
(tz->polling_frequency / 10));
end:
len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return_VALUE(len);
return 0;
}
static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_thermal_polling_seq_show,
PDE(inode)->data);
}
static int
acpi_thermal_write_polling (
......@@ -1075,7 +1058,7 @@ acpi_thermal_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_THERMAL_FILE_STATE));
else {
entry->read_proc = acpi_thermal_read_state;
entry->proc_fops = &acpi_thermal_state_fops;
entry->data = acpi_driver_data(device);
}
......@@ -1087,7 +1070,7 @@ acpi_thermal_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_THERMAL_FILE_TEMPERATURE));
else {
entry->read_proc = acpi_thermal_read_temperature;
entry->proc_fops = &acpi_thermal_temp_fops;
entry->data = acpi_driver_data(device);
}
......@@ -1099,7 +1082,7 @@ acpi_thermal_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_THERMAL_FILE_POLLING_FREQ));
else {
entry->read_proc = acpi_thermal_read_trip_points;
entry->proc_fops = &acpi_thermal_trip_fops;
entry->write_proc = acpi_thermal_write_trip_points;
entry->data = acpi_driver_data(device);
}
......@@ -1112,7 +1095,7 @@ acpi_thermal_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_THERMAL_FILE_COOLING_MODE));
else {
entry->read_proc = acpi_thermal_read_cooling_mode;
entry->proc_fops = &acpi_thermal_cooling_fops;
entry->write_proc = acpi_thermal_write_cooling_mode;
entry->data = acpi_driver_data(device);
}
......@@ -1125,7 +1108,7 @@ acpi_thermal_add_fs (
"Unable to create '%s' fs entry\n",
ACPI_THERMAL_FILE_POLLING_FREQ));
else {
entry->read_proc = acpi_thermal_read_polling;
entry->proc_fops = &acpi_thermal_polling_fops;
entry->write_proc = acpi_thermal_write_polling;
entry->data = acpi_driver_data(device);
}
......
......@@ -41,6 +41,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/version.h>
#include <acconfig.h>
......@@ -100,6 +101,47 @@ MODULE_LICENSE("GPL");
#define HCI_VIDEO_OUT_CRT 0x2
#define HCI_VIDEO_OUT_TV 0x4
static int toshiba_lcd_open_fs(struct inode *inode, struct file *file);
static int toshiba_video_open_fs(struct inode *inode, struct file *file);
static int toshiba_fan_open_fs(struct inode *inode, struct file *file);
static int toshiba_keys_open_fs(struct inode *inode, struct file *file);
static int toshiba_version_open_fs(struct inode *inode, struct file *file);
static struct file_operations toshiba_lcd_fops = {
.open = toshiba_lcd_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations toshiba_video_fops = {
.open = toshiba_video_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations toshiba_fan_fops = {
.open = toshiba_fan_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations toshiba_keys_fops = {
.open = toshiba_keys_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct file_operations toshiba_version_fops = {
.open = toshiba_version_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/* utility
*/
......@@ -126,22 +168,6 @@ snscanf(const char* str, int n, const char* format, ...)
return result;
}
/* This is the common code at the end of every proc read handler. I don't
* understand it yet.
*/
static int
end_proc_read(const char* p, char* page, off_t off, int count,
char** start, int* eof)
{
int len = (p - page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/* acpi interface wrappers
*/
......@@ -259,29 +285,27 @@ static int key_event_valid;
/* proc file handlers
*/
static int
proc_read_lcd(char* page, char** start, off_t off, int count, int* eof,
void* context)
static int toshiba_lcd_seq_show(struct seq_file *seq, void *offset)
{
char* p = page;
u32 hci_result;
u32 value;
if (off != 0) goto end;
hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result);
if (hci_result == HCI_SUCCESS) {
value = value >> HCI_LCD_BRIGHTNESS_SHIFT;
p += sprintf(p, "brightness: %d\n", value);
p += sprintf(p, "brightness_levels: %d\n",
HCI_LCD_BRIGHTNESS_LEVELS);
} else {
p += sprintf(p, "ERROR\n");
goto end;
}
seq_printf(seq, "brightness: %d\n"
"brightness_levels: %d\n",
value,
HCI_LCD_BRIGHTNESS_LEVELS);
} else
seq_puts(seq, "ERROR\n");
return 0;
}
end:
return end_proc_read(p, page, off, count, start, eof);
static int toshiba_lcd_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, toshiba_lcd_seq_show, NULL);
}
static int
......@@ -306,31 +330,31 @@ proc_write_lcd(struct file* file, const char* buffer, unsigned long count,
return count;
}
static int
proc_read_video(char* page, char** start, off_t off, int count, int* eof,
void* context)
static int toshiba_video_seq_show(struct seq_file *seq, void *offset)
{
char* p = page;
u32 hci_result;
u32 value;
if (off != 0) goto end;
hci_read1(HCI_VIDEO_OUT, &value, &hci_result);
if (hci_result == HCI_SUCCESS) {
int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
int is_tv = (value & HCI_VIDEO_OUT_TV ) ? 1 : 0;
p += sprintf(p, "lcd_out: %d\n", is_lcd);
p += sprintf(p, "crt_out: %d\n", is_crt);
p += sprintf(p, "tv_out: %d\n", is_tv);
} else {
p += sprintf(p, "ERROR\n");
goto end;
}
seq_printf(seq, "lcd_out: %d\n"
"crt_out: %d\n"
"tv_out: %d\n",
is_lcd,
is_crt,
is_tv);
} else
seq_puts(seq, "ERROR\n");
return 0;
}
end:
return end_proc_read(p, page, off, count, start, eof);
static int toshiba_video_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, toshiba_video_seq_show, NULL);
}
static int
......@@ -376,27 +400,26 @@ proc_write_video(struct file* file, const char* buffer, unsigned long count,
return count;
}
static int
proc_read_fan(char* page, char** start, off_t off, int count, int* eof,
void* context)
static int toshiba_fan_seq_show(struct seq_file *seq, void *offset)
{
char* p = page;
u32 hci_result;
u32 value;
if (off != 0) goto end;
hci_read1(HCI_FAN, &value, &hci_result);
if (hci_result == HCI_SUCCESS) {
p += sprintf(p, "running: %d\n", (value > 0));
p += sprintf(p, "force_on: %d\n", force_fan);
} else {
p += sprintf(p, "ERROR\n");
goto end;
}
seq_printf(seq, "running: %d\n"
"force_on: %d\n",
(value > 0),
force_fan);
} else
seq_puts(seq, "ERROR\n");
return 0;
}
end:
return end_proc_read(p, page, off, count, start, eof);
static int toshiba_fan_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, toshiba_fan_seq_show, NULL);
}
static int
......@@ -420,16 +443,11 @@ proc_write_fan(struct file* file, const char* buffer, unsigned long count,
return count;
}
static int
proc_read_keys(char* page, char** start, off_t off, int count, int* eof,
void* context)
static int toshiba_keys_seq_show(struct seq_file *seq, void *offset)
{
char* p = page;
u32 hci_result;
u32 value;
if (off != 0) goto end;
if (!key_event_valid) {
hci_read1(HCI_SYSTEM_EVENT, &value, &hci_result);
if (hci_result == HCI_SUCCESS) {
......@@ -438,16 +456,23 @@ proc_read_keys(char* page, char** start, off_t off, int count, int* eof,
} else if (hci_result == HCI_EMPTY) {
/* better luck next time */
} else {
p += sprintf(p, "ERROR\n");
seq_puts(seq, "ERROR\n");
goto end;
}
}
p += sprintf(p, "hotkey_ready: %d\n", key_event_valid);
p += sprintf(p, "hotkey: 0x%04x\n", last_key_event);
seq_printf(seq, "hotkey_ready: %d\n"
"hotkey: 0x%04x\n",
key_event_valid,
last_key_event);
end:
return end_proc_read(p, page, off, count, start, eof);
return 0;
}
static int toshiba_keys_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, toshiba_keys_seq_show, NULL);
}
static int
......@@ -466,20 +491,19 @@ proc_write_keys(struct file* file, const char* buffer, unsigned long count,
return count;
}
static int
proc_read_version(char* page, char** start, off_t off, int count, int* eof,
void* context)
static int toshiba_version_seq_show(struct seq_file *seq, void *offset)
{
char* p = page;
if (off != 0) goto end;
seq_printf(seq, "driver: %s\n"
"proc_interface: %d\n",
TOSHIBA_ACPI_VERSION,
PROC_INTERFACE_VERSION);
p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION);
p += sprintf(p, "proc_interface: %d\n",
PROC_INTERFACE_VERSION);
return 0;
}
end:
return end_proc_read(p, page, off, count, start, eof);
static int toshiba_version_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, toshiba_version_seq_show, NULL);
}
/* proc and module init
......@@ -490,24 +514,38 @@ add_device(void)
{
struct proc_dir_entry* proc;
proc = create_proc_read_entry(PROC_LCD, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, proc_read_lcd, 0);
if (proc) proc->write_proc = proc_write_lcd;
proc = create_proc_entry(PROC_LCD, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir);
if (proc) {
proc->proc_fops = &toshiba_lcd_fops;
proc->write_proc = proc_write_lcd;
}
proc = create_proc_read_entry(PROC_VIDEO, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, proc_read_video, 0);
if (proc) proc->write_proc = proc_write_video;
proc = create_proc_entry(PROC_VIDEO, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir);
if (proc) {
proc->proc_fops = &toshiba_video_fops;
proc->write_proc = proc_write_video;
}
proc = create_proc_read_entry(PROC_FAN, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, proc_read_fan, 0);
if (proc) proc->write_proc = proc_write_fan;
proc = create_proc_entry(PROC_FAN, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir);
if (proc) {
proc->proc_fops = &toshiba_fan_fops;
proc->write_proc = proc_write_fan;
}
proc = create_proc_read_entry(PROC_KEYS, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, proc_read_keys, 0);
if (proc) proc->write_proc = proc_write_keys;
proc = create_proc_entry(PROC_KEYS, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir);
if (proc) {
proc->proc_fops = &toshiba_keys_fops;
proc->write_proc = proc_write_keys;
}
proc = create_proc_read_entry(PROC_VERSION, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, proc_read_version, 0);
proc = create_proc_entry(PROC_VERSION, S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir);
if (proc)
proc->proc_fops = &toshiba_version_fops;
return(AE_OK);
}
......
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