8 #include <linux/kernel.h>
9 #include <linux/module.h>
11 #include <linux/errno.h>
26 static char *pvc_linename[
PVC_NLINES] = {
"line1",
"line2"};
27 #define DISPLAY_DIR_NAME "display"
28 static int scroll_dir, scroll_interval;
32 static void pvc_display(
unsigned long data)
43 static int pvc_line_proc_show(
struct seq_file *
m,
void *
v)
47 if (lineno < 0 || lineno > PVC_NLINES) {
61 return single_open(file, pvc_line_proc_show, PDE(inode)->data);
64 static ssize_t pvc_line_proc_write(
struct file *file,
const char __user *
buf,
67 int lineno = *(
int *)PDE(file->
f_path.dentry->d_inode)->data;
71 BUG_ON(lineno < 0 || lineno > PVC_NLINES);
73 len =
min(count,
sizeof(kbuf) - 1);
78 if (len > 0 && kbuf[len - 1] ==
'\n')
82 strncpy(pvc_lines[lineno], kbuf, len);
83 pvc_lines[
lineno][len] =
'\0';
86 tasklet_schedule(&pvc_display_tasklet);
93 .open = pvc_line_proc_open,
97 .write = pvc_line_proc_write,
100 static ssize_t pvc_scroll_proc_write(
struct file *file,
const char __user *buf,
101 size_t count, loff_t *pos)
107 len =
min(count,
sizeof(kbuf) - 1);
115 if (scroll_interval != 0)
124 scroll_interval = -
cmd;
127 scroll_interval =
cmd;
136 static int pvc_scroll_proc_show(
struct seq_file *m,
void *v)
139 seq_printf(m,
"%d\n", scroll_dir * scroll_interval);
145 static int pvc_scroll_proc_open(
struct inode *inode,
struct file *file)
152 .open = pvc_scroll_proc_open,
156 .write = pvc_scroll_proc_write,
163 else if (scroll_dir > 0)
170 static void pvc_proc_cleanup(
void)
181 static int __init pvc_proc_init(
void)
187 if (pvc_display_dir ==
NULL)
196 &pvc_line_proc_fops, &pvc_linedata[i]);
197 if (proc_entry ==
NULL)
200 proc_entry = proc_create(
"scroll", 0644, pvc_display_dir,
201 &pvc_scroll_proc_fops);
202 if (proc_entry ==
NULL)