diff mbox

[03/10] ashmem: Avoid touching mm/shmem.c while we're in staging

Message ID 1324003864-26776-4-git-send-email-john.stultz@linaro.org
State Superseded
Headers show

Commit Message

John Stultz Dec. 16, 2011, 2:50 a.m. UTC
This patch cuts out the mm/shmem.c modifications from the
original ashmem patch, because while we're in staging we
shouldn't be modifiying anything outside of the staging dir.

This patch likely needs the closest review to ensure the
shmem_file_set() replacement code is correct.

NOTE: This patch will be folded into the previous before
pushing the patch queue to staging.

CC: Brian Swetland <swetland@google.com>
CC: Colin Cross <ccross@android.com>
CC: Arve Hjønnevåg <arve@android.com>
CC: Dima Zavin <dima@android.com>
CC: Robert Love <rlove@google.com>
CC: Greg KH <greg@kroah.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/staging/android/ashmem.c |   20 ++++++++++++++------
 include/linux/mm.h               |    1 -
 mm/shmem.c                       |   16 ++++++----------
 3 files changed, 20 insertions(+), 17 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 34a5f8b..5775c6c 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -247,13 +247,21 @@  static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
 	}
 	get_file(asma->file);
 
-	if (vma->vm_flags & VM_SHARED)
-		shmem_set_file(vma, asma->file);
-	else {
-		if (vma->vm_file)
-			fput(vma->vm_file);
-		vma->vm_file = asma->file;
+	/*
+	 * XXX - Reworked to use shmem_zero_setup() instead of 
+	 * shmem_set_file while we're in staging. -jstultz
+	 */
+	if (vma->vm_flags & VM_SHARED) {
+		ret = shmem_zero_setup(vma);
+		if (ret) {
+			fput(asma->file);
+			goto out;
+		}
 	}
+
+	if (vma->vm_file)
+		fput(vma->vm_file);
+	vma->vm_file = asma->file;
 	vma->vm_flags |= VM_CAN_NONLINEAR;
 
 out:
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b880638..4baadd1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -872,7 +872,6 @@  extern bool skip_free_areas_node(unsigned int flags, int nid);
 
 int shmem_lock(struct file *file, int lock, struct user_struct *user);
 struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
-void shmem_set_file(struct vm_area_struct *vma, struct file *file);
 int shmem_zero_setup(struct vm_area_struct *);
 
 extern int can_do_mlock(void);
diff --git a/mm/shmem.c b/mm/shmem.c
index 7adc113..1e4fdd7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2526,15 +2526,6 @@  put_memory:
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);
 
-void shmem_set_file(struct vm_area_struct *vma, struct file *file)
-{
-	if (vma->vm_file)
-		fput(vma->vm_file);
-	vma->vm_file = file;
-	vma->vm_ops = &shmem_vm_ops;
-	vma->vm_flags |= VM_CAN_NONLINEAR;
-}
-
 /**
  * shmem_zero_setup - setup a shared anonymous mapping
  * @vma: the vma to be mmapped is prepared by do_mmap_pgoff
@@ -2548,7 +2539,12 @@  int shmem_zero_setup(struct vm_area_struct *vma)
 	if (IS_ERR(file))
 		return PTR_ERR(file);
 
-	shmem_set_file(vma, file);
+	if (vma->vm_file)
+		fput(vma->vm_file);
+	vma->vm_file = file;
+	vma->vm_ops = &shmem_vm_ops;
+	vma->vm_flags |= VM_CAN_NONLINEAR;
+
 	return 0;
 }