Commit fa8d3377 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo

Merge conectiva.com.br:/home/BK/acpi-2.5.old

into conectiva.com.br:/home/BK/acpi-2.5
parents cebce9d8 1a21cc1e
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/types.h> #include <linux/types.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"
...@@ -53,6 +54,7 @@ MODULE_LICENSE("GPL"); ...@@ -53,6 +54,7 @@ MODULE_LICENSE("GPL");
int acpi_ac_add (struct acpi_device *device); int acpi_ac_add (struct acpi_device *device);
int acpi_ac_remove (struct acpi_device *device, int type); 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 = { static struct acpi_driver acpi_ac_driver = {
.name = ACPI_AC_DRIVER_NAME, .name = ACPI_AC_DRIVER_NAME,
...@@ -69,6 +71,12 @@ struct acpi_ac { ...@@ -69,6 +71,12 @@ struct acpi_ac {
unsigned long state; 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 AC Adapter Management
...@@ -103,53 +111,40 @@ acpi_ac_get_state ( ...@@ -103,53 +111,40 @@ acpi_ac_get_state (
struct proc_dir_entry *acpi_ac_dir = NULL; struct proc_dir_entry *acpi_ac_dir = NULL;
static int int acpi_ac_seq_show(struct seq_file *seq, void *offset)
acpi_ac_read_state (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_ac *ac = (struct acpi_ac *) data; struct acpi_ac *ac = (struct acpi_ac *) seq->private;
char *p = page;
int len = 0;
ACPI_FUNCTION_TRACE("acpi_ac_read_state"); ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
if (!ac || (off != 0)) if (!ac)
goto end; return 0;
if (acpi_ac_get_state(ac)) { if (acpi_ac_get_state(ac)) {
p += sprintf(p, "ERROR: Unable to read AC Adapter state\n"); seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
goto end; return 0;
} }
p += sprintf(p, "state: "); seq_puts(seq, "state: ");
switch (ac->state) { switch (ac->state) {
case ACPI_AC_STATUS_OFFLINE: case ACPI_AC_STATUS_OFFLINE:
p += sprintf(p, "off-line\n"); seq_puts(seq, "off-line\n");
break; break;
case ACPI_AC_STATUS_ONLINE: case ACPI_AC_STATUS_ONLINE:
p += sprintf(p, "on-line\n"); seq_puts(seq, "on-line\n");
break; break;
default: default:
p += sprintf(p, "unknown\n"); seq_puts(seq, "unknown\n");
break; break;
} }
end: return 0;
len = (p - page); }
if (len <= off+count) *eof = 1;
*start = page + off; static int acpi_ac_open_fs(struct inode *inode, struct file *file)
len -= off; {
if (len>count) len = count; return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
if (len<0) len = 0;
return_VALUE(len);
} }
static int static int
acpi_ac_add_fs ( acpi_ac_add_fs (
...@@ -174,7 +169,7 @@ acpi_ac_add_fs ( ...@@ -174,7 +169,7 @@ acpi_ac_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_AC_FILE_STATE)); ACPI_AC_FILE_STATE));
else { else {
entry->read_proc = acpi_ac_read_state; entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device); entry->data = acpi_driver_data(device);
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/types.h> #include <linux/types.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"
...@@ -69,6 +70,7 @@ MODULE_LICENSE("GPL"); ...@@ -69,6 +70,7 @@ MODULE_LICENSE("GPL");
int acpi_button_add (struct acpi_device *device); int acpi_button_add (struct acpi_device *device);
int acpi_button_remove (struct acpi_device *device, int type); 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 = { static struct acpi_driver acpi_button_driver = {
.name = ACPI_BUTTON_DRIVER_NAME, .name = ACPI_BUTTON_DRIVER_NAME,
...@@ -87,6 +89,12 @@ struct acpi_button { ...@@ -87,6 +89,12 @@ struct acpi_button {
unsigned long pushed; 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) FS Interface (/proc)
...@@ -94,39 +102,26 @@ struct acpi_button { ...@@ -94,39 +102,26 @@ struct acpi_button {
static struct proc_dir_entry *acpi_button_dir = NULL; static struct proc_dir_entry *acpi_button_dir = NULL;
static int static int acpi_button_seq_show(struct seq_file *seq, void *offset)
acpi_button_read_info (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
struct acpi_button *button = (struct acpi_button *) data; struct acpi_button *button = (struct acpi_button *) seq->private;
char *p = page;
int len = 0;
ACPI_FUNCTION_TRACE("acpi_button_read_info"); ACPI_FUNCTION_TRACE("acpi_button_seq_show");
if (!button || !button->device) 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)); acpi_device_name(button->device));
end: return 0;
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);
} }
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 static int
acpi_button_add_fs ( acpi_button_add_fs (
struct acpi_device *device) struct acpi_device *device)
...@@ -170,7 +165,7 @@ acpi_button_add_fs ( ...@@ -170,7 +165,7 @@ acpi_button_add_fs (
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_BUTTON_FILE_INFO)); ACPI_BUTTON_FILE_INFO));
else { else {
entry->read_proc = acpi_button_read_info; entry->proc_fops = &acpi_button_fops;
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