Commit 687258f7 authored by John Stultz's avatar John Stultz Committed by Greg Kroah-Hartman

ion: Fix compat support to use proper compat ioctl numbers

The compat support added to ion didn't provide compat ioctl numbers
(who's value depends on the compat structure size). So 32bit
applications would get an error when trying to make ioctl calls.

This patch adds the needed COMPAT_ macros and uses them in the
compat_ion_ioctl, translating them to their non-compat cmd when
calling the normal ioctl call.
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c3a2fe03
...@@ -35,6 +35,12 @@ struct compat_ion_custom_data { ...@@ -35,6 +35,12 @@ struct compat_ion_custom_data {
compat_ulong_t arg; compat_ulong_t arg;
}; };
#define COMPAT_ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
struct compat_ion_allocation_data)
#define COMPAT_ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
#define COMPAT_ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, \
struct compat_ion_custom_data)
static int compat_get_ion_allocation_data( static int compat_get_ion_allocation_data(
struct compat_ion_allocation_data __user *data32, struct compat_ion_allocation_data __user *data32,
struct ion_allocation_data __user *data) struct ion_allocation_data __user *data)
...@@ -105,7 +111,7 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -105,7 +111,7 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -ENOTTY; return -ENOTTY;
switch (cmd) { switch (cmd) {
case ION_IOC_ALLOC: case COMPAT_ION_IOC_ALLOC:
{ {
struct compat_ion_allocation_data __user *data32; struct compat_ion_allocation_data __user *data32;
struct ion_allocation_data __user *data; struct ion_allocation_data __user *data;
...@@ -119,13 +125,12 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -119,13 +125,12 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
err = compat_get_ion_allocation_data(data32, data); err = compat_get_ion_allocation_data(data32, data);
if (err) if (err)
return err; return err;
ret = filp->f_op->unlocked_ioctl(filp, ION_IOC_ALLOC,
ret = filp->f_op->unlocked_ioctl(filp, cmd,
(unsigned long)data); (unsigned long)data);
err = compat_put_ion_allocation_data(data32, data); err = compat_put_ion_allocation_data(data32, data);
return ret ? ret : err; return ret ? ret : err;
} }
case ION_IOC_FREE: case COMPAT_ION_IOC_FREE:
{ {
struct compat_ion_allocation_data __user *data32; struct compat_ion_allocation_data __user *data32;
struct ion_allocation_data __user *data; struct ion_allocation_data __user *data;
...@@ -140,10 +145,10 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -140,10 +145,10 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (err) if (err)
return err; return err;
return filp->f_op->unlocked_ioctl(filp, cmd, return filp->f_op->unlocked_ioctl(filp, ION_IOC_FREE,
(unsigned long)data); (unsigned long)data);
} }
case ION_IOC_CUSTOM: { case COMPAT_ION_IOC_CUSTOM: {
struct compat_ion_custom_data __user *data32; struct compat_ion_custom_data __user *data32;
struct ion_custom_data __user *data; struct ion_custom_data __user *data;
int err; int err;
...@@ -157,7 +162,7 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -157,7 +162,7 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (err) if (err)
return err; return err;
return filp->f_op->unlocked_ioctl(filp, cmd, return filp->f_op->unlocked_ioctl(filp, ION_IOC_CUSTOM,
(unsigned long)data); (unsigned long)data);
} }
case ION_IOC_SHARE: case ION_IOC_SHARE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment