Module: xenomai-rpm
Branch: queue/vfile
Commit: f0e0825fb2095a29adf36cd5d93e6d518cee60c3
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=f0e0825fb2095a29adf36cd5d93e6d518cee60c3

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu May 27 15:47:14 2010 +0200

rtipc: convert to vfile

---

 ksrc/drivers/ipc/bufp.c  |   38 +++++++++++++++++++++++++-------------
 ksrc/drivers/ipc/iddp.c  |   38 +++++++++++++++++++++++++-------------
 ksrc/drivers/ipc/rtipc.c |    9 +--------
 ksrc/drivers/ipc/xddp.c  |   38 +++++++++++++++++++++++++-------------
 4 files changed, 76 insertions(+), 47 deletions(-)

diff --git a/ksrc/drivers/ipc/bufp.c b/ksrc/drivers/ipc/bufp.c
index 7517b79..714849f 100644
--- a/ksrc/drivers/ipc/bufp.c
+++ b/ksrc/drivers/ipc/bufp.c
@@ -76,26 +76,38 @@ static struct xnmap *portmap;
 
 #ifdef CONFIG_PROC_FS
 
-static ssize_t __bufp_link_proc(char *buf, int count, void *data)
+static char *__bufp_link_target(void *obj)
 {
-       struct bufp_socket *sk = data;
-       return snprintf(buf, count, "%d", sk->name.sipc_port);
+       struct bufp_socket *sk = obj;
+       char *buf;
+
+       /* XXX: older kernels don't have kasprintf(). */
+       buf = kmalloc(32, GFP_KERNEL);
+       if (buf == NULL)
+               return buf;
+
+       snprintf(buf, 32, "%d", sk->name.sipc_port);
+
+       return buf;
 }
 
-static struct xnpnode __bufp_pnode = {
+extern struct xnptree rtipc_ptree;
 
-       .dir = NULL,
-       .type = "bufp",
-       .entries = 0,
-       .link_proc = &__bufp_link_proc,
-       .root = &rtipc_ptree,
+static struct xnpnode_link __bufp_pnode = {
+       .node = {
+               .dirname = "bufp",
+               .root = &rtipc_ptree,
+               .ops = &xnregistry_vlink_ops,
+       },
+       .target = __bufp_link_target,
 };
 
 #else /* !CONFIG_PROC_FS */
 
-static struct xnpnode __bufp_pnode = {
-
-       .type = "bufp"
+static struct xnpnode_link __bufp_pnode = {
+       .node = {
+               .dirname = "bufp",
+       },
 };
 
 #endif /* !CONFIG_PROC_FS */
@@ -717,7 +729,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv,
 
        if (*sk->label) {
                ret = xnregistry_enter(sk->label, sk,
-                                      &sk->handle, &__bufp_pnode);
+                                      &sk->handle, &__bufp_pnode.node);
                if (ret) {
                        xnarch_free_host_mem(sk->bufmem, sk->bufsz);
                        goto fail;
diff --git a/ksrc/drivers/ipc/iddp.c b/ksrc/drivers/ipc/iddp.c
index 8a1b079..706c119 100644
--- a/ksrc/drivers/ipc/iddp.c
+++ b/ksrc/drivers/ipc/iddp.c
@@ -81,26 +81,38 @@ static int poolwait;
 
 #ifdef CONFIG_PROC_FS
 
-static ssize_t __iddp_link_proc(char *buf, int count, void *data)
+static char *__iddp_link_target(void *obj)
 {
-       struct iddp_socket *sk = data;
-       return snprintf(buf, count, "%d", sk->name.sipc_port);
+       struct iddp_socket *sk = obj;
+       char *buf;
+
+       /* XXX: older kernels don't have kasprintf(). */
+       buf = kmalloc(32, GFP_KERNEL);
+       if (buf == NULL)
+               return buf;
+
+       snprintf(buf, 32, "%d", sk->name.sipc_port);
+
+       return buf;
 }
 
-static struct xnpnode __iddp_pnode = {
+extern struct xnptree rtipc_ptree;
 
-       .dir = NULL,
-       .type = "iddp",
-       .entries = 0,
-       .link_proc = &__iddp_link_proc,
-       .root = &rtipc_ptree,
+static struct xnpnode_link __iddp_pnode = {
+       .node = {
+               .dirname = "iddp",
+               .root = &rtipc_ptree,
+               .ops = &xnregistry_vlink_ops,
+       },
+       .target = __iddp_link_target,
 };
 
 #else /* !CONFIG_PROC_FS */
 
-static struct xnpnode __iddp_pnode = {
-
-       .type = "iddp"
+static struct xnpnode_link __iddp_pnode = {
+       .node = {
+               .dirname = "iddp",
+       },
 };
 
 #endif /* !CONFIG_PROC_FS */
@@ -578,7 +590,7 @@ static int __iddp_bind_socket(struct rtipc_private *priv,
 
        if (*sk->label) {
                ret = xnregistry_enter(sk->label, sk,
-                                      &sk->handle, &__iddp_pnode);
+                                      &sk->handle, &__iddp_pnode.node);
                if (ret) {
                        if (poolsz > 0)
                                xnheap_destroy(&sk->privpool,
diff --git a/ksrc/drivers/ipc/rtipc.c b/ksrc/drivers/ipc/rtipc.c
index 71629cb..e5a0bc0 100644
--- a/ksrc/drivers/ipc/rtipc.c
+++ b/ksrc/drivers/ipc/rtipc.c
@@ -35,14 +35,7 @@ static struct rtipc_protocol *protocols[IPCPROTO_MAX] = {
 #endif
 };
 
-#ifdef CONFIG_PROC_FS
-struct xnptree rtipc_ptree = {
-
-       .dir = NULL,
-       .name = "rtipc",
-       .entries = 0,
-};
-#endif /* CONFIG_PROC_FS */
+DEFINE_XNPTREE(rtipc_ptree, "rtipc");
 
 int rtipc_get_arg(rtdm_user_info_t *user_info,
                  void *dst, const void *src, size_t len)
diff --git a/ksrc/drivers/ipc/xddp.c b/ksrc/drivers/ipc/xddp.c
index c2a65e9..bcf272f 100644
--- a/ksrc/drivers/ipc/xddp.c
+++ b/ksrc/drivers/ipc/xddp.c
@@ -73,26 +73,38 @@ static int portmap[CONFIG_XENO_OPT_PIPE_NRDEV]; /* indexes 
RTDM fildes */
 
 #ifdef CONFIG_PROC_FS
 
-static ssize_t __xddp_link_proc(char *buf, int count, void *data)
+static char *__xddp_link_target(void *obj)
 {
-       struct xddp_socket *sk = data;
-       return snprintf(buf, count, "/dev/rtp%d", sk->minor);
+       struct xddp_socket *sk = obj;
+       char *buf;
+
+       /* XXX: older kernels don't have kasprintf(). */
+       buf = kmalloc(32, GFP_KERNEL);
+       if (buf == NULL)
+               return buf;
+
+       snprintf(buf, 32, "/dev/rtp%d", sk->minor);
+
+       return buf;
 }
 
-static struct xnpnode __xddp_pnode = {
+extern struct xnptree rtipc_ptree;
 
-       .dir = NULL,
-       .type = "xddp",
-       .entries = 0,
-       .link_proc = &__xddp_link_proc,
-       .root = &rtipc_ptree,
+static struct xnpnode_link __xddp_pnode = {
+       .node = {
+               .dirname = "xddp",
+               .root = &rtipc_ptree,
+               .ops = &xnregistry_vlink_ops,
+       },
+       .target = __xddp_link_target,
 };
 
 #else /* !CONFIG_PROC_FS */
 
-static struct xnpnode __xddp_pnode = {
-
-       .type = "xddp"
+static struct xnpnode_link __xddp_pnode = {
+       .node = {
+               .dirname = "xddp",
+       },
 };
 
 #endif /* !CONFIG_PROC_FS */
@@ -755,7 +767,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
 
        if (*sk->label) {
                ret = xnregistry_enter(sk->label, sk, &sk->handle,
-                                      &__xddp_pnode);
+                                      &__xddp_pnode.node);
                if (ret) {
                        /* The release handler will cleanup the pool for us. */
                        xnpipe_disconnect(sk->minor);


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

Reply via email to