ion: Add reserve function to ion
authorRebecca Schultz Zavin <rebecca@android.com>
Fri, 13 Dec 2013 22:23:38 +0000 (14:23 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2013 16:55:36 +0000 (08:55 -0800)
Rather than requiring each platform call memblock_remove or reserve
from the board file, add this to ion

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
[jstultz: modified patch to apply to staging directory]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion.h

index bca8d9e925e407e75861b238ca359409bde7034b..004c0d4f7353f0056a60f31ad94b8c7cf0a034a1 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fs.h>
 #include <linux/anon_inodes.h>
 #include <linux/list.h>
+#include <linux/memblock.h>
 #include <linux/miscdevice.h>
 #include <linux/export.h>
 #include <linux/mm.h>
@@ -1185,3 +1186,19 @@ void ion_device_destroy(struct ion_device *dev)
        /* XXX need to free the heaps and clients ? */
        kfree(dev);
 }
+
+void __init ion_reserve(struct ion_platform_data *data)
+{
+       int i, ret;
+
+       for (i = 0; i < data->nr; i++) {
+               if (data->heaps[i].size == 0)
+                       continue;
+               ret = memblock_reserve(data->heaps[i].base,
+                                      data->heaps[i].size);
+               if (ret)
+                       pr_err("memblock reserve of %x@%lx failed\n",
+                              data->heaps[i].size,
+                              data->heaps[i].base);
+       }
+}
index 87f6a45bcd1f75f8621c8d58cdf8c93e028616e3..4e012b86a839bcd1419b98fea4e5966df8141bb7 100644 (file)
@@ -86,6 +86,17 @@ struct ion_platform_data {
        struct ion_platform_heap heaps[];
 };
 
+/**
+ * ion_reserve() - reserve memory for ion heaps if applicable
+ * @data:      platform data specifying starting physical address and
+ *             size
+ *
+ * Calls memblock reserve to set aside memory for heaps that are
+ * located at specific memory addresses or of specfic sizes not
+ * managed by the kernel
+ */
+void ion_reserve(struct ion_platform_data *data);
+
 /**
  * ion_client_create() -  allocate a client and returns it
  * @dev:       the global ion device