Module: xenomai-jki
Branch: queues/proc
Commit: 37a1da48b0348b7ba006dee92bd3de20cf81cc97
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=37a1da48b0348b7ba006dee92bd3de20cf81cc97

Author: Wolfgang Mauerer <wolfgang.maue...@siemens.com>
Date:   Fri Apr 16 18:07:33 2010 +0200

native: Convert cond registry proc entry to the seq_file mechanism

Signed-off-by: Wolfgang Mauerer <wolfgang.maue...@siemens.com>
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 ksrc/skins/native/cond.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/ksrc/skins/native/cond.c b/ksrc/skins/native/cond.c
index 86f83ff..081c2af 100644
--- a/ksrc/skins/native/cond.c
+++ b/ksrc/skins/native/cond.c
@@ -50,13 +50,11 @@
 
 #ifdef CONFIG_PROC_FS
 
-static int __cond_read_proc(char *page,
-                           char **start,
-                           off_t off, int count, int *eof, void *data)
+#include <linux/seq_file.h>
+
+static int cond_seq_show(struct seq_file *f, void *v)
 {
-       RT_COND *cond = (RT_COND *)data;
-       char *p = page;
-       int len;
+       RT_COND *cond = (RT_COND *)f->private;
        spl_t s;
 
        xnlock_get_irqsave(&nklock, s);
@@ -70,7 +68,7 @@ static int __cond_read_proc(char *page,
 
                while (holder) {
                        xnthread_t *sleeper = link2thread(holder, plink);
-                       p += sprintf(p, "+%s\n", xnthread_name(sleeper));
+                       seq_printf(f, "+%s\n", xnthread_name(sleeper));
                        holder =
                            nextpq(xnsynch_wait_queue(&cond->synch_base),
                                   holder);
@@ -79,18 +77,21 @@ static int __cond_read_proc(char *page,
 
        xnlock_put_irqrestore(&nklock, s);
 
-       len = (p - page) - off;
-       if (len <= off + count)
-               *eof = 1;
-       *start = page + off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
+       return 0;
+}
 
-       return len;
+static int cond_seq_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, cond_seq_show, PDE(inode)->data);
 }
 
+static struct file_operations cond_proc_fops = {
+        .owner          = THIS_MODULE,
+        .open           = cond_seq_open,
+        .read           = seq_read,
+        .llseek         = seq_lseek,
+};
+
 extern xnptree_t __native_ptree;
 
 static xnpnode_t __cond_pnode = {
@@ -98,8 +99,9 @@ static xnpnode_t __cond_pnode = {
        .dir = NULL,
        .type = "condvars",
        .entries = 0,
-       .read_proc = &__cond_read_proc,
+       .read_proc = NULL,
        .write_proc = NULL,
+       .fops = &cond_proc_fops,
        .root = &__native_ptree,
 };
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to