staging: android: ion: Merge ion-ioctl.c into ion.c
authorAndrew F. Davis <afd@ti.com>
Fri, 11 Jan 2019 18:05:12 +0000 (12:05 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Jan 2019 09:42:27 +0000 (10:42 +0100)
The file ion-ioctl.c is now much to small and tightly integrated
with the main ion.c file to justify keeping it separate. Merge
this file.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/Makefile
drivers/staging/android/ion/ion-ioctl.c [deleted file]
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion.h

index bb30bf8..17f3a75 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_ION) +=   ion.o ion-ioctl.o ion_heap.o
+obj-$(CONFIG_ION) += ion.o ion_heap.o
 obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o
 obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o
 obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o
diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
deleted file mode 100644 (file)
index b366f97..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2011 Google, Inc.
- */
-
-#include <linux/kernel.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-
-#include "ion.h"
-
-union ion_ioctl_arg {
-       struct ion_allocation_data allocation;
-       struct ion_heap_query query;
-};
-
-static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
-{
-       switch (cmd) {
-       case ION_IOC_HEAP_QUERY:
-               if (arg->query.reserved0 ||
-                   arg->query.reserved1 ||
-                   arg->query.reserved2)
-                       return -EINVAL;
-               break;
-       default:
-               break;
-       }
-
-       return 0;
-}
-
-long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-       int ret = 0;
-       union ion_ioctl_arg data;
-
-       if (_IOC_SIZE(cmd) > sizeof(data))
-               return -EINVAL;
-
-       /*
-        * The copy_from_user is unconditional here for both read and write
-        * to do the validate. If there is no write for the ioctl, the
-        * buffer is cleared
-        */
-       if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
-               return -EFAULT;
-
-       ret = validate_ioctl_arg(cmd, &data);
-       if (ret) {
-               pr_warn_once("%s: ioctl validate failed\n", __func__);
-               return ret;
-       }
-
-       if (!(_IOC_DIR(cmd) & _IOC_WRITE))
-               memset(&data, 0, sizeof(data));
-
-       switch (cmd) {
-       case ION_IOC_ALLOC:
-       {
-               int fd;
-
-               fd = ion_alloc(data.allocation.len,
-                              data.allocation.heap_id_mask,
-                              data.allocation.flags);
-               if (fd < 0)
-                       return fd;
-
-               data.allocation.fd = fd;
-
-               break;
-       }
-       case ION_IOC_HEAP_QUERY:
-               ret = ion_query_heaps(&data.query);
-               break;
-       default:
-               return -ENOTTY;
-       }
-
-       if (_IOC_DIR(cmd) & _IOC_READ) {
-               if (copy_to_user((void __user *)arg, &data, _IOC_SIZE(cmd)))
-                       return -EFAULT;
-       }
-       return ret;
-}
index de1ca5e..2d6d8c0 100644 (file)
@@ -390,7 +390,7 @@ static const struct dma_buf_ops dma_buf_ops = {
        .unmap = ion_dma_buf_kunmap,
 };
 
-int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
+static int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
 {
        struct ion_device *dev = internal_dev;
        struct ion_buffer *buffer = NULL;
@@ -447,7 +447,7 @@ int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
        return fd;
 }
 
-int ion_query_heaps(struct ion_heap_query *query)
+static int ion_query_heaps(struct ion_heap_query *query)
 {
        struct ion_device *dev = internal_dev;
        struct ion_heap_data __user *buffer = u64_to_user_ptr(query->heaps);
@@ -492,6 +492,81 @@ out:
        return ret;
 }
 
+union ion_ioctl_arg {
+       struct ion_allocation_data allocation;
+       struct ion_heap_query query;
+};
+
+static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
+{
+       switch (cmd) {
+       case ION_IOC_HEAP_QUERY:
+               if (arg->query.reserved0 ||
+                   arg->query.reserved1 ||
+                   arg->query.reserved2)
+                       return -EINVAL;
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       int ret = 0;
+       union ion_ioctl_arg data;
+
+       if (_IOC_SIZE(cmd) > sizeof(data))
+               return -EINVAL;
+
+       /*
+        * The copy_from_user is unconditional here for both read and write
+        * to do the validate. If there is no write for the ioctl, the
+        * buffer is cleared
+        */
+       if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
+               return -EFAULT;
+
+       ret = validate_ioctl_arg(cmd, &data);
+       if (ret) {
+               pr_warn_once("%s: ioctl validate failed\n", __func__);
+               return ret;
+       }
+
+       if (!(_IOC_DIR(cmd) & _IOC_WRITE))
+               memset(&data, 0, sizeof(data));
+
+       switch (cmd) {
+       case ION_IOC_ALLOC:
+       {
+               int fd;
+
+               fd = ion_alloc(data.allocation.len,
+                              data.allocation.heap_id_mask,
+                              data.allocation.flags);
+               if (fd < 0)
+                       return fd;
+
+               data.allocation.fd = fd;
+
+               break;
+       }
+       case ION_IOC_HEAP_QUERY:
+               ret = ion_query_heaps(&data.query);
+               break;
+       default:
+               return -ENOTTY;
+       }
+
+       if (_IOC_DIR(cmd) & _IOC_READ) {
+               if (copy_to_user((void __user *)arg, &data, _IOC_SIZE(cmd)))
+                       return -EFAULT;
+       }
+       return ret;
+}
+
 static const struct file_operations ion_fops = {
        .owner          = THIS_MODULE,
        .unlocked_ioctl = ion_ioctl,
index ff455fd..084f246 100644 (file)
@@ -205,10 +205,6 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
 int ion_heap_buffer_zero(struct ion_buffer *buffer);
 int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot);
 
-int ion_alloc(size_t len,
-             unsigned int heap_id_mask,
-             unsigned int flags);
-
 /**
  * ion_heap_init_shrinker
  * @heap:              the heap
@@ -330,8 +326,4 @@ 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);
 
-long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
-
-int ion_query_heaps(struct ion_heap_query *query);
-
 #endif /* _ION_H */