summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinyu Chen <xinyu.chen@freescale.com>2012-08-07 10:30:29 +0800
committerXinyu Chen <xinyu.chen@freescale.com>2012-08-07 10:32:13 +0800
commit511f74fdef926a8e26d5aaa64135a4745a3e65fa (patch)
treea524bd0b37f002e5d3b4cef7be01ec732542bdd3
parent6c65604f0fe6e60b50bb204fc05a0134f8ced60b (diff)
ENGR00219578 ion: refine the ioctl of ION_IOC_PHYS
The ioctl should return 0 when successful. And the physical address is returned by the parameter structures. Signed-off-by: Xinyu Chen <xinyu.chen@freescale.com>
-rw-r--r--drivers/gpu/ion/ion.c12
-rw-r--r--include/linux/ion.h15
2 files changed, 22 insertions, 5 deletions
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 47ba2155e39b..e606d1bdd3c3 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1015,18 +1015,22 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
case ION_IOC_PHYS:
{
- struct ion_handle_data data;
+ struct ion_phys_data data;
ion_phys_addr_t phys;
int len;
bool valid;
if (copy_from_user(&data, (void __user *)arg,
- sizeof(struct ion_handle_data)))
+ sizeof(struct ion_phys_data)))
return -EFAULT;
valid = ion_phys(client, data.handle, &phys, &len);
if (valid)
- return 0;
- return phys;
+ return -1;
+ data.phys = phys;
+ if (copy_to_user((void __user *)arg, &data,
+ sizeof(struct ion_phys_data)))
+ return -EFAULT;
+ return 0;
}
default:
return -ENOTTY;
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 22b9d621d299..2cc8e0c7d096 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -265,6 +265,19 @@ struct ion_fd_data {
};
/**
+ * struct ion_phys_data - passed to/from userspace for a handle/phys addr pair
+ * @handle: a handle
+ * @phys: a return physcial address
+ *
+ * For ION_IOC_PHYS ioctl
+ * the phys return the ion phys address
+ */
+struct ion_phys_data {
+ struct ion_handle *handle;
+ unsigned long phys;
+};
+
+/**
* struct ion_handle_data - a handle passed to/from the kernel
* @handle: a handle
*/
@@ -347,6 +360,6 @@ struct ion_custom_data {
* Takes an ion_fd_data struct with the handle field populated with a valid
* opaque handle. Returns the address
*/
-#define ION_IOC_PHYS _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
+#define ION_IOC_PHYS _IOWR(ION_IOC_MAGIC, 7, struct ion_phys_data)
#endif /* _LINUX_ION_H */