@@ -42,3 +42,10 @@ config ION_CMA_HEAP
Choose this option to enable CMA heaps with Ion. This heap is backed
by the Contiguous Memory Allocator (CMA). If your system has these
regions, you should say Y here.
+
+config ION_COMPAT_INTERFACE
+ bool "Legacy /dev/ion interface support"
+ depends on ION
+ help
+ Choose this option to enable the legacy /dev/ion interface which
+ provides compatibility with userspace designed for 4.12+ kernels
@@ -43,6 +43,7 @@ static unsigned int ion_ioctl_dir(unsigned int cmd)
}
}
+#ifdef CONFIG_ION_COMPAT_INTERFACE
long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int ret = 0;
@@ -102,6 +103,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
return ret;
}
+#endif
long ion_heap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
@@ -500,14 +500,6 @@ static const struct file_operations ion_heap_fops = {
#endif
};
-static const struct file_operations ion_fops = {
- .owner = THIS_MODULE,
- .unlocked_ioctl = ion_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = ion_ioctl,
-#endif
-};
-
static int debug_shrink_set(void *data, u64 val)
{
struct ion_heap *heap = data;
@@ -619,15 +611,19 @@ void ion_device_add_heap(struct ion_heap *heap)
}
EXPORT_SYMBOL(ion_device_add_heap);
-static int ion_device_create(void)
+#ifdef CONFIG_ION_COMPAT_INTERFACE
+static const struct file_operations ion_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = ion_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ion_ioctl,
+#endif
+};
+
+static int ion_create_legacy_interface(struct ion_device *idev)
{
- struct ion_device *idev;
int ret;
- idev = kzalloc(sizeof(*idev), GFP_KERNEL);
- if (!idev)
- return -ENOMEM;
-
idev->dev.minor = MISC_DYNAMIC_MINOR;
idev->dev.name = "ion";
idev->dev.fops = &ion_fops;
@@ -636,8 +632,25 @@ static int ion_device_create(void)
if (ret) {
pr_err("ion: failed to register misc device.\n");
kfree(idev);
- return ret;
}
+ return ret;
+}
+#else
+#define ion_create_legacy_interface(x) 0
+#endif
+
+static int ion_device_create(void)
+{
+ struct ion_device *idev;
+ int ret;
+
+ idev = kzalloc(sizeof(*idev), GFP_KERNEL);
+ if (!idev)
+ return -ENOMEM;
+
+ ret = ion_create_legacy_interface(idev);
+ if (ret)
+ return ret;
idev->debug_root = debugfs_create_dir("ion", NULL);
idev->buffers = RB_ROOT;
@@ -333,7 +333,9 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page);
int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
int nr_to_scan);
+#ifdef CONFIG_ION_COMPAT_INTERFACE
long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+#endif
long ion_heap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
int ion_query_heaps(struct ion_heap_query *query);
Add a config option to make the "legacy" /dev/ion interface optional. Not yet clear if this will come out of staging or not, but to help with the transition. Cc: Laura Abbott <labbott@redhat.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Liam Mark <lmark@codeaurora.org> Cc: Brian Starkey <Brian.Starkey@arm.com> Cc: Andrew F. Davis <afd@ti.com> Cc: Alistair Strachan <astrachan@google.com> Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz <john.stultz@linaro.org> --- drivers/staging/android/ion/Kconfig | 7 ++++++ drivers/staging/android/ion/ion-ioctl.c | 2 ++ drivers/staging/android/ion/ion.c | 43 +++++++++++++++++++++------------ drivers/staging/android/ion/ion.h | 2 ++ 4 files changed, 39 insertions(+), 15 deletions(-)