summaryrefslogtreecommitdiffstats
path: root/sculld
diff options
context:
space:
mode:
authorLuis Ortega Perez de Villar <luiorpe1@upv.es>2013-08-20 19:50:13 +0200
committerJavier Martinez Canillas <javier.martinez@collabora.co.uk>2013-09-28 13:35:44 +0200
commit88814fb5e184f9cfa197ae44abad60df16c6ca5a (patch)
tree72c39a0ef6f834bd61533a774f5b49a9248be975 /sculld
parent85934acb414650b3bfc0b2e262e492019a503784 (diff)
downloadldd3-88814fb5e184f9cfa197ae44abad60df16c6ca5a.tar.gz
sculld: main: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as it is deprecated, but rather use proc_create() and seq_file instead.
Diffstat (limited to 'sculld')
-rw-r--r--sculld/main.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/sculld/main.c b/sculld/main.c
index 8a6ecb1..f11f7d6 100644
--- a/sculld/main.c
+++ b/sculld/main.c
@@ -24,6 +24,7 @@
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/fcntl.h> /* O_ACCMODE */
#include <linux/aio.h>
#include <asm/uaccess.h>
@@ -66,61 +67,54 @@ static struct ldd_driver sculld_driver = {
* The proc filesystem: function to read and entry
*/
-void sculld_proc_offset(char *buf, char **start, off_t *offset, int *len)
-{
- if (*offset == 0)
- return;
- if (*offset >= *len) {
- /* Not there yet */
- *offset -= *len;
- *len = 0;
- } else {
- /* We're into the interesting stuff now */
- *start = buf + *offset;
- *offset = 0;
- }
-}
-
/* FIXME: Do we need this here?? It be ugly */
-int sculld_read_procmem(char *buf, char **start, off_t offset,
- int count, int *eof, void *data)
+int sculld_read_procmem(struct seq_file *m, void *v)
{
- int i, j, order, qset, len = 0;
- int limit = count - 80; /* Don't print more than this */
+ int i, j, order, qset;
+ int limit = m->size - 80; /* Don't print more than this */
struct sculld_dev *d;
- *start = buf;
for(i = 0; i < sculld_devs; i++) {
d = &sculld_devices[i];
if (down_interruptible (&d->sem))
return -ERESTARTSYS;
qset = d->qset; /* retrieve the features of each device */
order = d->order;
- len += sprintf(buf+len,"\nDevice %i: qset %i, order %i, sz %li\n",
+ seq_printf(m,"\nDevice %i: qset %i, order %i, sz %li\n",
i, qset, order, (long)(d->size));
for (; d; d = d->next) { /* scan the list */
- len += sprintf(buf+len," item at %p, qset at %p\n",d,d->data);
- sculld_proc_offset (buf, start, &offset, &len);
- if (len > limit)
+ seq_printf(m," item at %p, qset at %p\n",d,d->data);
+ if (m->count > limit)
goto out;
if (d->data && !d->next) /* dump only the last item - save space */
for (j = 0; j < qset; j++) {
if (d->data[j])
- len += sprintf(buf+len," % 4i:%8p\n",j,d->data[j]);
- sculld_proc_offset (buf, start, &offset, &len);
- if (len > limit)
+ seq_printf(m," % 4i:%8p\n",j,d->data[j]);
+ if (m->count > limit)
goto out;
}
}
out:
up (&sculld_devices[i].sem);
- if (len > limit)
+ if (m->count > limit)
break;
}
- *eof = 1;
- return len;
+ return 0;
}
+static int sculld_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, sculld_read_procmem, NULL);
+}
+
+static struct file_operations sculld_proc_ops = {
+ .owner = THIS_MODULE,
+ .open = sculld_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release
+};
+
#endif /* SCULLD_USE_PROC */
/*
@@ -605,7 +599,7 @@ int sculld_init(void)
#ifdef SCULLD_USE_PROC /* only when available */
- create_proc_read_entry("sculldmem", 0, NULL, sculld_read_procmem, NULL);
+ proc_create("sculldmem", 0, NULL, &sculld_proc_ops);
#endif
return 0; /* succeed */