Commit 399dc43bc29fe1ac19340c56c0df84aa0ea53c85
Committed by
David S. Miller
1 parent
fbaa20f66a
Exists in
master
and in
7 other branches
sparc: switch /proc/led to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 21 additions and 13 deletions Side-by-side Diff
arch/sparc/kernel/led.c
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | #include <linux/module.h> |
3 | 3 | #include <linux/init.h> |
4 | 4 | #include <linux/proc_fs.h> |
5 | +#include <linux/seq_file.h> | |
5 | 6 | #include <linux/string.h> |
6 | 7 | #include <linux/jiffies.h> |
7 | 8 | #include <linux/timer.h> |
8 | 9 | |
9 | 10 | |
10 | 11 | |
11 | 12 | |
12 | 13 | |
... | ... | @@ -45,21 +46,22 @@ |
45 | 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 | - int *eof, void *data) | |
49 | +static int led_proc_show(struct seq_file *m, void *v) | |
50 | 50 | { |
51 | - int len = 0; | |
52 | - | |
53 | 51 | if (get_auxio() & AUXIO_LED) |
54 | - len = sprintf(buf, "on\n"); | |
52 | + seq_puts(m, "on\n"); | |
55 | 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, | |
62 | - unsigned long count, void *data) | |
63 | +static ssize_t led_proc_write(struct file *file, const char __user *buffer, | |
64 | + size_t count, loff_t *ppos) | |
63 | 65 | { |
64 | 66 | char *buf = NULL; |
65 | 67 | |
... | ... | @@ -103,6 +105,15 @@ |
103 | 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 | 117 | static struct proc_dir_entry *led; |
107 | 118 | |
108 | 119 | #define LED_VERSION "0.1" |
109 | 120 | |
... | ... | @@ -112,12 +123,9 @@ |
112 | 123 | init_timer(&led_blink_timer); |
113 | 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 | 127 | if (!led) |
117 | 128 | return -ENOMEM; |
118 | - | |
119 | - led->read_proc = led_read_proc; /* reader function */ | |
120 | - led->write_proc = led_write_proc; /* writer function */ | |
121 | 129 | led->owner = THIS_MODULE; |
122 | 130 | |
123 | 131 | printk(KERN_INFO |