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

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

parent d4705f43
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/acpi.h> #include <asm/acpi.h>
...@@ -32,8 +33,25 @@ ACPI_MODULE_NAME ("sleep") ...@@ -32,8 +33,25 @@ ACPI_MODULE_NAME ("sleep")
#define ACPI_SYSTEM_FILE_SLEEP "sleep" #define ACPI_SYSTEM_FILE_SLEEP "sleep"
#define ACPI_SYSTEM_FILE_ALARM "alarm" #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 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 static void
acpi_power_off (void) acpi_power_off (void)
{ {
...@@ -271,43 +289,26 @@ acpi_suspend ( ...@@ -271,43 +289,26 @@ acpi_suspend (
return status; return status;
} }
static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
static int
acpi_system_read_sleep (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *data)
{ {
char *p = page;
int size;
int i; int i;
ACPI_FUNCTION_TRACE("acpi_system_read_sleep"); ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
if (off != 0)
goto end;
for (i = 0; i <= ACPI_STATE_S5; i++) { for (i = 0; i <= ACPI_STATE_S5; i++) {
if (sleep_states[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: return 0;
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);
} }
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 static int
acpi_system_write_sleep ( acpi_system_write_sleep (
...@@ -349,25 +350,12 @@ acpi_system_write_sleep ( ...@@ -349,25 +350,12 @@ acpi_system_write_sleep (
return_VALUE(count); return_VALUE(count);
} }
static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
static int
acpi_system_read_alarm (
char *page,
char **start,
off_t off,
int count,
int *eof,
void *context)
{ {
char *p = page;
int size = 0;
u32 sec, min, hr; u32 sec, min, hr;
u32 day, mo, yr; u32 day, mo, yr;
ACPI_FUNCTION_TRACE("acpi_system_read_alarm"); ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
if (off != 0)
goto end;
spin_lock(&rtc_lock); spin_lock(&rtc_lock);
...@@ -427,21 +415,19 @@ acpi_system_read_alarm ( ...@@ -427,21 +415,19 @@ acpi_system_read_alarm (
yr += 2000; yr += 2000;
#endif #endif
p += sprintf(p,"%4.4u-", yr); seq_printf(seq,"%4.4u-", yr);
p += (mo > 12) ? sprintf(p, "**-") : sprintf(p, "%2.2u-", mo); (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
p += (day > 31) ? sprintf(p, "** ") : sprintf(p, "%2.2u ", day); (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
p += (hr > 23) ? sprintf(p, "**:") : sprintf(p, "%2.2u:", hr); (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
p += (min > 59) ? sprintf(p, "**:") : sprintf(p, "%2.2u:", min); (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
p += (sec > 59) ? sprintf(p, "**\n") : sprintf(p, "%2.2u\n", sec); (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
end: return 0;
size = p - page; }
if (size < count) *eof = 1;
else if (size > count) size = count; static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
if (size < 0) size = 0; {
*start = page; return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
return_VALUE(size);
} }
...@@ -687,7 +673,7 @@ static int __init acpi_sleep_init(void) ...@@ -687,7 +673,7 @@ static int __init acpi_sleep_init(void)
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_SLEEP)); ACPI_SYSTEM_FILE_SLEEP));
else { else {
entry->read_proc = acpi_system_read_sleep; entry->proc_fops = &acpi_system_sleep_fops;
entry->write_proc = acpi_system_write_sleep; entry->write_proc = acpi_system_write_sleep;
} }
...@@ -699,7 +685,7 @@ static int __init acpi_sleep_init(void) ...@@ -699,7 +685,7 @@ static int __init acpi_sleep_init(void)
"Unable to create '%s' fs entry\n", "Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_ALARM)); ACPI_SYSTEM_FILE_ALARM));
else { else {
entry->read_proc = acpi_system_read_alarm; entry->proc_fops = &acpi_system_alarm_fops;
entry->write_proc = acpi_system_write_alarm; entry->write_proc = acpi_system_write_alarm;
} }
......
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