From: Wolfgang Mauerer <wolfgang.maue...@siemens.com>

Signed-off-by: Wolfgang Mauerer <wolfgang.maue...@siemens.com>
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 ksrc/skins/native/alarm.c |   43 +++++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/ksrc/skins/native/alarm.c b/ksrc/skins/native/alarm.c
index 1130dfb..4ff14a7 100644
--- a/ksrc/skins/native/alarm.c
+++ b/ksrc/skins/native/alarm.c
@@ -45,20 +45,18 @@
 
 #ifdef CONFIG_PROC_FS
 
-static int __alarm_read_proc(char *page,
-                            char **start,
-                            off_t off, int count, int *eof, void *data)
+#include <linux/seq_file.h>
+
+static int alarm_seq_show(struct seq_file *f, void *v)
 {
-       RT_ALARM *alarm = (RT_ALARM *)data;
-       char *p = page;
-       int len;
+       RT_ALARM *alarm = (RT_ALARM *)f->private;
        spl_t s;
 
        xnlock_get_irqsave(&nklock, s);
 
-       p += sprintf(p, "interval=%Lu:expiries=%lu\n",
-                    rt_timer_tsc2ns(xntimer_interval(&alarm->timer_base)),
-                    alarm->expiries);
+       seq_printf(f, "interval=%Lu:expiries=%lu\n",
+                  rt_timer_tsc2ns(xntimer_interval(&alarm->timer_base)),
+                  alarm->expiries);
 
 #ifdef CONFIG_XENO_OPT_PERVASIVE
        {
@@ -67,7 +65,7 @@ static int __alarm_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(&alarm->synch_base),
                                   holder);
@@ -77,18 +75,22 @@ static int __alarm_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 alarm_seq_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, alarm_seq_show, PDE(inode)->data);
 }
 
+static struct file_operations alarm_proc_fops = {
+        .owner          = THIS_MODULE,
+        .open           = alarm_seq_open,
+        .read           = seq_read,
+        .llseek         = seq_lseek,
+};
+
+
 extern xnptree_t __native_ptree;
 
 static xnpnode_t __alarm_pnode = {
@@ -96,8 +98,9 @@ static xnpnode_t __alarm_pnode = {
        .dir = NULL,
        .type = "alarms",
        .entries = 0,
-       .read_proc = &__alarm_read_proc,
+       .read_proc = NULL,
        .write_proc = NULL,
+       .fops = &alarm_proc_fops,
        .root = &__native_ptree,
 };
 
-- 
1.6.0.2


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

Reply via email to