diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-06-03 18:21:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-03 18:21:21 -0400 |
commit | 399dc43bc29fe1ac19340c56c0df84aa0ea53c85 (patch) | |
tree | f1d97d050aa87a1ea9212e57c0f6b62f8dab0831 /arch | |
parent | fbaa20f66a8283359523dfe961ebe66f0b8fac59 (diff) |
sparc: switch /proc/led to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc/kernel/led.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c index 59e9344e7a0d..adaaed4ea2fb 100644 --- a/arch/sparc/kernel/led.c +++ b/arch/sparc/kernel/led.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/init.h> | 3 | #include <linux/init.h> |
4 | #include <linux/proc_fs.h> | 4 | #include <linux/proc_fs.h> |
5 | #include <linux/seq_file.h> | ||
5 | #include <linux/string.h> | 6 | #include <linux/string.h> |
6 | #include <linux/jiffies.h> | 7 | #include <linux/jiffies.h> |
7 | #include <linux/timer.h> | 8 | #include <linux/timer.h> |
@@ -45,21 +46,22 @@ static void led_blink(unsigned long timeout) | |||
45 | add_timer(&led_blink_timer); | 46 | add_timer(&led_blink_timer); |
46 | } | 47 | } |
47 | 48 | ||
48 | static int led_read_proc(char *buf, char **start, off_t offset, int count, | 49 | static int led_proc_show(struct seq_file *m, void *v) |
49 | int *eof, void *data) | ||
50 | { | 50 | { |
51 | int len = 0; | ||
52 | |||
53 | if (get_auxio() & AUXIO_LED) | 51 | if (get_auxio() & AUXIO_LED) |
54 | len = sprintf(buf, "on\n"); | 52 | seq_puts(m, "on\n"); |
55 | else | 53 | else |
56 | len = sprintf(buf, "off\n"); | 54 | seq_puts(m, "off\n"); |
55 | return 0; | ||
56 | } | ||
57 | 57 | ||
58 | return len; | 58 | static int led_proc_open(struct inode *inode, struct file *file) |
59 | { | ||
60 | return single_open(file, led_proc_show, NULL); | ||
59 | } | 61 | } |
60 | 62 | ||
61 | static int led_write_proc(struct file *file, const char __user *buffer, | 63 | static ssize_t led_proc_write(struct file *file, const char __user *buffer, |
62 | unsigned long count, void *data) | 64 | size_t count, loff_t *ppos) |
63 | { | 65 | { |
64 | char *buf = NULL; | 66 | char *buf = NULL; |
65 | 67 | ||
@@ -103,6 +105,15 @@ static int led_write_proc(struct file *file, const char __user *buffer, | |||
103 | return count; | 105 | return count; |
104 | } | 106 | } |
105 | 107 | ||
108 | static const struct file_operations led_proc_fops = { | ||
109 | .owner = THIS_MODULE, | ||
110 | .open = led_proc_open, | ||
111 | .read = seq_read, | ||
112 | .llseek = seq_lseek, | ||
113 | .release = single_release, | ||
114 | .write = led_proc_write, | ||
115 | }; | ||
116 | |||
106 | static struct proc_dir_entry *led; | 117 | static struct proc_dir_entry *led; |
107 | 118 | ||
108 | #define LED_VERSION "0.1" | 119 | #define LED_VERSION "0.1" |
@@ -112,12 +123,9 @@ static int __init led_init(void) | |||
112 | init_timer(&led_blink_timer); | 123 | init_timer(&led_blink_timer); |
113 | led_blink_timer.function = led_blink; | 124 | led_blink_timer.function = led_blink; |
114 | 125 | ||
115 | led = create_proc_entry("led", 0, NULL); | 126 | led = proc_create("led", 0, NULL, &led_proc_fops); |
116 | if (!led) | 127 | if (!led) |
117 | return -ENOMEM; | 128 | return -ENOMEM; |
118 | |||
119 | led->read_proc = led_read_proc; /* reader function */ | ||
120 | led->write_proc = led_write_proc; /* writer function */ | ||
121 | led->owner = THIS_MODULE; | 129 | led->owner = THIS_MODULE; |
122 | 130 | ||
123 | printk(KERN_INFO | 131 | printk(KERN_INFO |