summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <martinez.javier@gmail.com>2011-01-04 02:34:35 +0100
committerJavier Martinez Canillas <martinez.javier@gmail.com>2011-01-08 00:57:39 +0100
commit685330e5d22c51fd217d1f8c5f3034b5fc8b23aa (patch)
tree4e03b769dd114c3dae410dc71ac43199b8210d2e
parent87d437abf4974520392ad441f70b4f8eba3b4b3e (diff)
downloadldd3-685330e5d22c51fd217d1f8c5f3034b5fc8b23aa.tar.gz
tty: tiny_tty: Use seq_file instead read_proc
-rw-r--r--tty/tiny_tty.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/tty/tiny_tty.c b/tty/tiny_tty.c
index 7b42ecd..a440555 100644
--- a/tty/tiny_tty.c
+++ b/tty/tiny_tty.c
@@ -23,6 +23,7 @@
#include <linux/tty_flip.h>
#include <linux/serial.h>
#include <linux/sched.h>
+#include <linux/seq_file.h>
#include <asm/uaccess.h>
@@ -354,34 +355,21 @@ static int tiny_tiocmset(struct tty_struct *tty, struct file *file,
return 0;
}
-static int tiny_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
+static int tiny_proc_show(struct seq_file *m, void *v)
{
struct tiny_serial *tiny;
- off_t begin = 0;
- int length = 0;
int i;
- length += sprintf(page, "tinyserinfo:1.0 driver:%s\n", DRIVER_VERSION);
- for (i = 0; i < TINY_TTY_MINORS && length < PAGE_SIZE; ++i) {
+ seq_printf(m, "tinyserinfo:1.0 driver:%s\n", DRIVER_VERSION);
+ for (i = 0; i < TINY_TTY_MINORS; ++i) {
tiny = tiny_table[i];
if (tiny == NULL)
continue;
- length += sprintf(page+length, "%d\n", i);
- if ((length + begin) > (off + count))
- goto done;
- if ((length + begin) < off) {
- begin += length;
- length = 0;
- }
+ seq_printf(m, "%d\n", i);
}
- *eof = 1;
-done:
- if (off >= (length + begin))
- return 0;
- *start = page + (off-begin);
- return (count < begin+length-off) ? count : begin + length-off;
+
+ return 0;
}
#define tiny_ioctl tiny_ioctl_tiocgserial
@@ -505,9 +493,18 @@ static int tiny_ioctl(struct tty_struct *tty, struct file *file,
return -ENOIOCTLCMD;
}
+static int tiny_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, tiny_proc_show, NULL);
+}
+
+
static const struct file_operations serial_proc_fops = {
.owner = THIS_MODULE,
- .read = tiny_read_proc,
+ .open = tiny_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
};
static struct tty_operations serial_ops = {
@@ -516,9 +513,7 @@ static struct tty_operations serial_ops = {
.write = tiny_write,
.write_room = tiny_write_room,
.set_termios = tiny_set_termios,
-#ifdef CONFIG_PROC_FS
.proc_fops = &serial_proc_fops,
-#endif
.tiocmget = tiny_tiocmget,
.tiocmset = tiny_tiocmset,
.ioctl = tiny_ioctl,