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

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

native: Convert event registry proc file to seq_file

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

---

 ksrc/skins/native/event.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/ksrc/skins/native/event.c b/ksrc/skins/native/event.c
index 5b2a8b5..d674a89 100644
--- a/ksrc/skins/native/event.c
+++ b/ksrc/skins/native/event.c
@@ -47,18 +47,16 @@
 
 #ifdef CONFIG_PROC_FS
 
-static int __event_read_proc(char *page,
-                            char **start,
-                            off_t off, int count, int *eof, void *data)
+#include <linux/seq_file.h>
+
+static int event_seq_show(struct seq_file *f, void *v)
 {
-       RT_EVENT *event = (RT_EVENT *)data;
-       char *p = page;
-       int len;
+       RT_EVENT *event = (RT_EVENT *)f->private;
        spl_t s;
 
        xnlock_get_irqsave(&nklock, s);
 
-       p += sprintf(p, "=0x%lx\n", event->value);
+       seq_printf(f, "=0x%lx\n", event->value);
 
        if (xnsynch_nsleepers(&event->synch_base) > 0) {
                xnpholder_t *holder;
@@ -74,8 +72,8 @@ static int __event_read_proc(char *page,
                            (task->wait_args.event.
                             mode & EV_ANY) ? "any" : "all";
                        unsigned long mask = task->wait_args.event.mask;
-                       p += sprintf(p, "+%s (mask=0x%lx, %s)\n",
-                                    xnthread_name(sleeper), mask, mode);
+                       seq_printf(f, "+%s (mask=0x%lx, %s)\n",
+                                  xnthread_name(sleeper), mask, mode);
                        holder =
                            nextpq(xnsynch_wait_queue(&event->synch_base),
                                   holder);
@@ -84,18 +82,21 @@ static int __event_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 event_seq_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, event_seq_show, PDE(inode)->data);
 }
 
+static struct file_operations event_proc_fops = {
+        .owner          = THIS_MODULE,
+        .open           = event_seq_open,
+        .read           = seq_read,
+        .llseek         = seq_lseek,
+};
+
 extern xnptree_t __native_ptree;
 
 static xnpnode_t __event_pnode = {
@@ -103,8 +104,9 @@ static xnpnode_t __event_pnode = {
        .dir = NULL,
        .type = "events",
        .entries = 0,
-       .read_proc = &__event_read_proc,
+       .read_proc = NULL,
        .write_proc = NULL,
+       .fops = &event_proc_fops,
        .root = &__native_ptree,
 };
 


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

Reply via email to