]> Pileus Git - ~andy/linux/blobdiff - drivers/staging/android/ashmem.c
staging: android: ashmem: Add support for 32bit ashmem calls in a 64bit kernel
[~andy/linux] / drivers / staging / android / ashmem.c
index 38a9135a2f6dbe50cd840376d96b75dec55430b1..e681bdd9aa5f46fb31e2a1390c3559387b333bf2 100644 (file)
@@ -702,6 +702,23 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        return ret;
 }
 
+/* support of 32bit userspace on 64bit platforms */
+#ifdef CONFIG_COMPAT
+static long compat_ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+
+       switch (cmd) {
+       case COMPAT_ASHMEM_SET_SIZE:
+               cmd = ASHMEM_SET_SIZE;
+               break;
+       case COMPAT_ASHMEM_SET_PROT_MASK:
+               cmd = ASHMEM_SET_PROT_MASK;
+               break;
+       }
+       return ashmem_ioctl(file, cmd, arg);
+}
+#endif
+
 static const struct file_operations ashmem_fops = {
        .owner = THIS_MODULE,
        .open = ashmem_open,
@@ -710,7 +727,9 @@ static const struct file_operations ashmem_fops = {
        .llseek = ashmem_llseek,
        .mmap = ashmem_mmap,
        .unlocked_ioctl = ashmem_ioctl,
-       .compat_ioctl = ashmem_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = compat_ashmem_ioctl,
+#endif
 };
 
 static struct miscdevice ashmem_misc = {