X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fzoran_procfs.c;h=f0d9b13c3c6c524a6402a7631303b79ef47cd1dd;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=703d6bf8e516eb767626c5359af8f0b7a3fa153d;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c index 703d6bf8e..f0d9b13c3 100644 --- a/drivers/media/video/zoran_procfs.c +++ b/drivers/media/video/zoran_procfs.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -93,14 +94,6 @@ static const struct procfs_params_zr36067 zr67[] = { {NULL, 0, 0, 0}, }; -struct procfs_io { - char *buffer; - char *end; - int neof; - int count; - int count_current; -}; - static void setparam (struct zoran *zr, char *name, @@ -130,85 +123,34 @@ setparam (struct zoran *zr, } } -static int -print_procfs (struct procfs_io *io, - const char *fmt, - ...) -{ - va_list args; - int i; - - if (io->buffer >= io->end) { - io->neof++; - return 0; - } - if (io->count > io->count_current++) - return 0; - va_start(args, fmt); - i = vsprintf(io->buffer, fmt, args); - io->buffer += i; - va_end(args); - return i; -} - -static void -zoran_procfs_output (struct procfs_io *io, - void *data) +static int zoran_show(struct seq_file *p, void *v) { + struct zoran *zr = p->private; int i; - struct zoran *zr; - zr = (struct zoran *) data; - print_procfs(io, "ZR36067 registers:"); - for (i = 0; i < 0x130; i += 4) { - if (!(i % 16)) { - print_procfs(io, "\n%03X", i); - }; - print_procfs(io, " %08X ", btread(i)); - }; - print_procfs(io, "\n"); + seq_printf(p, "ZR36067 registers:\n"); + for (i = 0; i < 0x130; i += 16) + seq_printf(p, "%03X %08X %08X %08X %08X \n", i, + btread(i), btread(i+4), btread(i+8), btread(i+12)); + return 0; } -static int -zoran_read_proc (char *buffer, - char **start, - off_t offset, - int size, - int *eof, - void *data) +static int zoran_open(struct inode *inode, struct file *file) { - struct procfs_io io; - int nbytes; - - io.buffer = buffer; - io.end = buffer + size - 128; // Just to make it a little bit safer - io.count = offset; - io.count_current = 0; - io.neof = 0; - zoran_procfs_output(&io, data); - *start = (char *) (io.count_current - io.count); - nbytes = (int) (io.buffer - buffer); - *eof = !io.neof; - return nbytes; - - return 0; + struct zoran *data = PDE(inode)->data; + return single_open(file, zoran_show, data); } -static int -zoran_write_proc (struct file *file, - const char *buffer, - unsigned long count, - void *data) +static ssize_t zoran_write(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) { + struct zoran *zr = PDE(file->f_dentry->d_inode)->data; char *string, *sp; char *line, *ldelim, *varname, *svar, *tdelim; - struct zoran *zr; if (count > 32768) /* Stupidity filter */ return -EINVAL; - zr = (struct zoran *) data; - string = sp = vmalloc(count + 1); if (!string) { dprintk(1, @@ -222,8 +164,8 @@ zoran_write_proc (struct file *file, return -EFAULT; } string[count] = 0; - dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%lu data=%x\n", - ZR_DEVNAME(zr), file->f_dentry->d_name.name, count, (int) data); + dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%zu zr=%p\n", + ZR_DEVNAME(zr), file->f_dentry->d_name.name, count, zr); ldelim = " \t\n"; tdelim = "="; line = strpbrk(sp, ldelim); @@ -243,6 +185,14 @@ zoran_write_proc (struct file *file, return count; } + +static struct file_operations zoran_operations = { + .open = zoran_open, + .read = seq_read, + .write = zoran_write, + .llseek = seq_lseek, + .release = single_release, +}; #endif int @@ -252,11 +202,10 @@ zoran_proc_init (struct zoran *zr) char name[8]; snprintf(name, 7, "zoran%d", zr->id); - if ((zr->zoran_proc = create_proc_entry(name, 0, 0))) { - zr->zoran_proc->read_proc = zoran_read_proc; - zr->zoran_proc->write_proc = zoran_write_proc; + if ((zr->zoran_proc = create_proc_entry(name, 0, NULL))) { zr->zoran_proc->data = zr; zr->zoran_proc->owner = THIS_MODULE; + zr->zoran_proc->proc_fops = &zoran_operations; dprintk(2, KERN_INFO "%s: procfs entry /proc/%s allocated. data=%p\n", @@ -277,9 +226,8 @@ zoran_proc_cleanup (struct zoran *zr) char name[8]; snprintf(name, 7, "zoran%d", zr->id); - if (zr->zoran_proc) { - remove_proc_entry(name, 0); - } + if (zr->zoran_proc) + remove_proc_entry(name, NULL); zr->zoran_proc = NULL; #endif }