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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Fri Jun 17 15:02:22 2016 +0200

nucleus: replace do_munmap with vm_munmap

The more convenient vm_munmap is available since 3.4.0. Use it, and
provide a wrapper for kernels prior to 3.4.0.

---

 include/asm-generic/wrappers.h |   12 ++++++++++++
 ksrc/nucleus/heap.c            |    7 ++++---
 ksrc/skins/rtdm/drvlib.c       |    4 +---
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index b4b4291..fa5a42a 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -744,6 +744,18 @@ unsigned long vm_mmap(struct file *file, unsigned long 
addr,
        return ret;
 }
 
+static inline int vm_munmap(unsigned long start, size_t len)
+{
+       struct mm_struct *mm = current->mm;
+       int ret;
+
+       down_write(&mm->mmap_sem);
+       ret = do_munmap(mm, start, len);
+       up_write(&mm->mmap_sem);
+
+       return ret;
+}
+
 #endif /* LINUX_VERSION_CODE < 3.4.0 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c
index 568ba27..ffabfc3 100644
--- a/ksrc/nucleus/heap.c
+++ b/ksrc/nucleus/heap.c
@@ -1412,10 +1412,11 @@ void xnheap_destroy_mapped(xnheap_t *heap,
         * epilogue in case no more mapping exists.
         */
        if (mapaddr) {
-               down_write(&current->mm->mmap_sem);
+               spin_lock(&kheapq_lock);
                heap->archdep.release = NULL;
-               do_munmap(current->mm, (unsigned long)mapaddr, len);
-               up_write(&current->mm->mmap_sem);
+               spin_unlock(&kheapq_lock);
+
+               vm_munmap((unsigned long)mapaddr, len);
        }
 
        /*
diff --git a/ksrc/skins/rtdm/drvlib.c b/ksrc/skins/rtdm/drvlib.c
index 1320cf0..fc29ede 100644
--- a/ksrc/skins/rtdm/drvlib.c
+++ b/ksrc/skins/rtdm/drvlib.c
@@ -2104,9 +2104,7 @@ int rtdm_munmap(rtdm_user_info_t *user_info, void *ptr, 
size_t len)
 
        XENO_ASSERT(RTDM, xnpod_root_p(), return -EPERM;);
 
-       down_write(&user_info->mm->mmap_sem);
-       err = do_munmap(user_info->mm, (unsigned long)ptr, len);
-       up_write(&user_info->mm->mmap_sem);
+       err = vm_munmap((unsigned long)ptr, len);
 
        return err;
 }


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

Reply via email to