Module: xenomai-jki
Branch: for-forge
Commit: 7cd7f0e48794c84179d33127dd0589e7a7fb8d04
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=7cd7f0e48794c84179d33127dd0589e7a7fb8d04

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Wed Aug 21 09:02:01 2013 +0200

cobalt/vfile: Adjust procfs usage to latest kernel API

proc_dir_entry became opaque and create_proc_entry is gone now. Switch
to the new patterns and wrap PDE_DATA as well as proc_create_data for
older kernels.

Note: CAN and Analogy require a more extensive update.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 .../cobalt/include/asm-generic/xenomai/wrappers.h  |   11 +++++++
 kernel/cobalt/vfile.c                              |   31 +++++++-------------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 02eeed0..601fc30 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -72,5 +72,16 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
 #include <linux/sched/rt.h>
 #endif /* LINUX >= 3.9.0 */
+ 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
+#include <linux/proc_fs.h>
+
+#define PDE_DATA(inode)        PROC_I(inode)->pde->data
+
+static inline void proc_remove(struct proc_dir_entry *pde)
+{
+       remove_proc_entry(pde->name, pde->parent);
+}
+#endif /* < 3.10 */
 
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
diff --git a/kernel/cobalt/vfile.c b/kernel/cobalt/vfile.c
index 6907f2e..932f38a 100644
--- a/kernel/cobalt/vfile.c
+++ b/kernel/cobalt/vfile.c
@@ -148,8 +148,7 @@ static void vfile_snapshot_free(struct 
xnvfile_snapshot_iterator *it, void *buf)
 
 static int vfile_snapshot_open(struct inode *inode, struct file *file)
 {
-       struct proc_dir_entry *pde = PDE(inode);
-       struct xnvfile_snapshot *vfile = pde->data;
+       struct xnvfile_snapshot *vfile = PDE_DATA(inode);
        struct xnvfile_snapshot_ops *ops = vfile->ops;
        struct xnvfile_snapshot_iterator *it;
        int revtag, ret, nrdata;
@@ -318,8 +317,8 @@ static int vfile_snapshot_release(struct inode *inode, 
struct file *file)
 ssize_t vfile_snapshot_write(struct file *file, const char __user *buf,
                             size_t size, loff_t *ppos)
 {
-       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
-       struct xnvfile_snapshot *vfile = pde->data;
+       struct xnvfile_snapshot *vfile =
+               PDE_DATA(file->f_path.dentry->d_inode);
        struct xnvfile_input input;
        ssize_t ret;
 
@@ -414,12 +413,10 @@ int xnvfile_init_snapshot(const char *name,
 
        mode = vfile->ops->store ? 0644 : 0444;
        ppde = parent->entry.pde;
-       pde = create_proc_entry(name, mode, ppde);
+       pde = proc_create_data(name, mode, ppde, &vfile_snapshot_fops, vfile);
        if (pde == NULL)
                return -ENOMEM;
 
-       pde->proc_fops = &vfile_snapshot_fops;
-       pde->data = vfile;
        vfile->entry.parent = parent;
        vfile->entry.pde = pde;
 
@@ -505,8 +502,7 @@ static struct seq_operations vfile_regular_ops = {
 
 static int vfile_regular_open(struct inode *inode, struct file *file)
 {
-       struct proc_dir_entry *pde = PDE(inode);
-       struct xnvfile_regular *vfile = pde->data;
+       struct xnvfile_regular *vfile = PDE_DATA(inode);
        struct xnvfile_regular_ops *ops = vfile->ops;
        struct xnvfile_regular_iterator *it;
        struct seq_file *seq;
@@ -574,8 +570,8 @@ static int vfile_regular_release(struct inode *inode, 
struct file *file)
 ssize_t vfile_regular_write(struct file *file, const char __user *buf,
                            size_t size, loff_t *ppos)
 {
-       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
-       struct xnvfile_regular *vfile = pde->data;
+       struct xnvfile_regular *vfile =
+               PDE_DATA(file->f_path.dentry->d_inode);
        struct xnvfile_input input;
        ssize_t ret;
 
@@ -650,12 +646,10 @@ int xnvfile_init_regular(const char *name,
 
        mode = vfile->ops->store ? 0644 : 0444;
        ppde = parent->entry.pde;
-       pde = create_proc_entry(name, mode, ppde);
+       pde = proc_create_data(name, mode, ppde, &vfile_regular_fops, vfile);
        if (pde == NULL)
                return -ENOMEM;
 
-       pde->proc_fops = &vfile_regular_fops;
-       pde->data = vfile;
        vfile->entry.parent = parent;
        vfile->entry.pde = pde;
 
@@ -693,7 +687,7 @@ int xnvfile_init_dir(const char *name,
                parent = &sysroot;
 
        ppde = parent->entry.pde;
-       pde = create_proc_entry(name, S_IFDIR, ppde);
+       pde = proc_mkdir(name, ppde);
        if (pde == NULL)
                return -ENOMEM;
 
@@ -762,10 +756,7 @@ EXPORT_SYMBOL_GPL(xnvfile_init_link);
  */
 void xnvfile_destroy(struct xnvfile *vfile)
 {
-       struct proc_dir_entry *ppde;
-
-       ppde = vfile->parent ? vfile->parent->entry.pde : nkvfroot.entry.pde;
-       remove_proc_entry(vfile->pde->name, ppde);
+       proc_remove(vfile->pde);
 }
 EXPORT_SYMBOL_GPL(xnvfile_destroy);
 
@@ -961,7 +952,7 @@ int __init xnvfile_init_root(void)
        struct xnvfile_directory *vdir = &nkvfroot;
        struct proc_dir_entry *pde;
 
-       pde = create_proc_entry("xenomai", S_IFDIR, NULL);
+       pde = proc_mkdir("xenomai", NULL);
        if (pde == NULL)
                return -ENOMEM;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to