Module: xenomai-2.6
Branch: master
Commit: 6eebf66becdfeb6c3fb6db62936ec5030ef8dd97
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=6eebf66becdfeb6c3fb6db62936ec5030ef8dd97

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

nucleus: 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>

---

 include/asm-generic/wrappers.h |   26 ++++++++++++++++++++++++++
 ksrc/nucleus/vfile.c           |   29 +++++++++--------------------
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index 77b82ba..0a4b45b 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -760,4 +760,30 @@ unsigned long vm_mmap(struct file *file, unsigned long 
addr,
 #define wrap_select_timers(mask) ipipe_timers_request()
 #endif
 
+#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);
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+static inline struct proc_dir_entry *
+proc_create_data(const char *name, mode_t mode, struct proc_dir_entry *parent,
+                const struct file_operations *proc_fops, void *data)
+{
+       struct proc_dir_entry *pde = create_proc_entry(name, mode, parent);
+
+       if (pde) {
+               pde->proc_fops = proc_fops;
+               pde->data = data;
+       }
+       return pde;
+}
+#endif /* < 2.6.26 */
+#endif /* < 3.10 */
+
 #endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index a6ad363..8da3bc7 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -146,8 +146,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;
@@ -324,8 +323,7 @@ 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(wrap_f_inode(file));
-       struct xnvfile_snapshot *vfile = pde->data;
+       struct xnvfile_snapshot *vfile = PDE_DATA(wrap_f_inode(file));
        struct xnvfile_input input;
        ssize_t ret;
 
@@ -420,16 +418,14 @@ 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;
        wrap_proc_dir_entry_owner(pde);
 
        vfile->entry.parent = parent;
        vfile->entry.pde = pde;
-       pde->data = vfile;
 
        return 0;
 }
@@ -513,8 +509,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;
@@ -582,8 +577,7 @@ 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(wrap_f_inode(file));
-       struct xnvfile_regular *vfile = pde->data;
+       struct xnvfile_regular *vfile = PDE_DATA(wrap_f_inode(file));
        struct xnvfile_input input;
        ssize_t ret;
 
@@ -658,16 +652,14 @@ 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;
        wrap_proc_dir_entry_owner(pde);
 
        vfile->entry.parent = parent;
        vfile->entry.pde = pde;
-       pde->data = vfile;
 
        return 0;
 }
@@ -703,7 +695,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;
 
@@ -774,10 +766,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);
 
@@ -971,7 +960,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