diff mbox

[08/10] ashmem: Fix arguments to ashmem_shrink

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

Commit Message

John Stultz Dec. 16, 2011, 2:51 a.m. UTC
From: Colin Cross <ccross@android.com>

The arguments to shrink functions have changed, update
ashmem_shrink to match.

Change-Id: Id279d22d761a2a7c4965c957960eef804d06cc07
Signed-off-by: Colin Cross <ccross@android.com>
[jstultz: tweaked commit subject]
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 |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 777e2b2..a78ba21 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -355,14 +355,14 @@  out:
  * chunks of ashmem regions LRU-wise one-at-a-time until we hit 'nr_to_scan'
  * pages freed.
  */
-static int ashmem_shrink(struct shrinker *s, int nr_to_scan, gfp_t gfp_mask)
+static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc)
 {
 	struct ashmem_range *range, *next;
 
 	/* We might recurse into filesystem code, so bail out if necessary */
-	if (nr_to_scan && !(gfp_mask & __GFP_FS))
+	if (sc->nr_to_scan && !(sc->gfp_mask & __GFP_FS))
 		return -1;
-	if (!nr_to_scan)
+	if (!sc->nr_to_scan)
 		return lru_count;
 
 	mutex_lock(&ashmem_mutex);
@@ -375,8 +375,8 @@  static int ashmem_shrink(struct shrinker *s, int nr_to_scan, gfp_t gfp_mask)
 		range->purged = ASHMEM_WAS_PURGED;
 		lru_del(range);
 
-		nr_to_scan -= range_size(range);
-		if (nr_to_scan <= 0)
+		sc->nr_to_scan -= range_size(range);
+		if (sc->nr_to_scan <= 0)
 			break;
 	}
 	mutex_unlock(&ashmem_mutex);
@@ -670,8 +670,13 @@  static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case ASHMEM_PURGE_ALL_CACHES:
 		ret = -EPERM;
 		if (capable(CAP_SYS_ADMIN)) {
-			ret = ashmem_shrink(&ashmem_shrinker, 0, GFP_KERNEL);
-			ashmem_shrink(&ashmem_shrinker, ret, GFP_KERNEL);
+			struct shrink_control sc = {
+				.gfp_mask = GFP_KERNEL,
+				.nr_to_scan = 0,
+			};
+			ret = ashmem_shrink(&ashmem_shrinker, &sc);
+			sc.nr_to_scan = ret;
+			ashmem_shrink(&ashmem_shrinker, &sc);
 		}
 		break;
 	}