ion: ioctl compatibility with userland using old api

As far as I can tell, flags passed by userland are now used to determine
buffer caching.

Note in ION_IOC_ALLOC_COMPAT we are currently forcing uncached buffer
allocations (needed to make a choice here).  This
may need to change.

Signed-off-by: Flemmard <flemmard@gmail.com>
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 7fee5ff..c56faa4 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -515,6 +515,13 @@
 	struct ion_handle *handle;
 };
 
+
+struct ion_allocation_data_compat {
+	size_t len;
+	size_t align;
+	unsigned int flags;
+	struct ion_handle *handle;
+};
 /**
  * struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair
  * @handle:	a handle
@@ -550,6 +557,19 @@
 	unsigned int cmd;
 	unsigned long arg;
 };
+
+struct ion_flush_data {
+        struct ion_handle *handle;
+        int fd;
+        void *vaddr;
+        unsigned int offset;
+        unsigned int length;
+};
+struct ion_flag_data {
+        struct ion_handle *handle;
+        unsigned long flags;
+};
+
 #define ION_IOC_MAGIC		'I'
 
 /**
@@ -561,6 +581,9 @@
 #define ION_IOC_ALLOC		_IOWR(ION_IOC_MAGIC, 0, \
 				      struct ion_allocation_data)
 
+
+#define ION_IOC_ALLOC_COMPAT		_IOWR(ION_IOC_MAGIC, 0, \
+				      struct ion_allocation_data_compat)
 /**
  * DOC: ION_IOC_FREE - free memory
  *
@@ -597,6 +620,7 @@
  * filed set to the corresponding opaque handle.
  */
 #define ION_IOC_IMPORT		_IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
+#define ION_IOC_IMPORT_COMPAT		_IOWR(ION_IOC_MAGIC, 5, int)
 
 /**
  * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
@@ -606,5 +630,13 @@
  */
 #define ION_IOC_CUSTOM		_IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
 
+#define ION_IOC_CLEAN_CACHES_COMPAT    _IOWR(ION_IOC_MAGIC, 7, \
+                                                struct ion_flush_data)
+#define ION_IOC_INV_CACHES_COMPAT      _IOWR(ION_IOC_MAGIC, 8, \
+                                                struct ion_flush_data)
+#define ION_IOC_CLEAN_INV_CACHES_COMPAT       _IOWR(ION_IOC_MAGIC, 9, \
+                                                struct ion_flush_data)
+#define ION_IOC_GET_FLAGS_COMPAT               _IOWR(ION_IOC_MAGIC, 10, \
+                                                struct ion_flag_data)
 
 #endif /* _LINUX_ION_H */