Merge tag 'compat-ioctl-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd...
[linux-2.6-block.git] / drivers / isdn / capi / capi.c
index ba8619524231ccde29093076e6196652d17dd69b..1675da34239b523db81f513cec73fe3308cbf3bf 100644 (file)
@@ -950,6 +950,34 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        return ret;
 }
 
+#ifdef CONFIG_COMPAT
+static long
+capi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       int ret;
+
+       if (cmd == CAPI_MANUFACTURER_CMD) {
+               struct {
+                       compat_ulong_t cmd;
+                       compat_uptr_t data;
+               } mcmd32;
+
+               if (!capable(CAP_SYS_ADMIN))
+                       return -EPERM;
+               if (copy_from_user(&mcmd32, compat_ptr(arg), sizeof(mcmd32)))
+                       return -EFAULT;
+
+               mutex_lock(&capi_mutex);
+               ret = capi20_manufacturer(mcmd32.cmd, compat_ptr(mcmd32.data));
+               mutex_unlock(&capi_mutex);
+
+               return ret;
+       }
+
+       return capi_unlocked_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static int capi_open(struct inode *inode, struct file *file)
 {
        struct capidev *cdev;
@@ -996,6 +1024,9 @@ static const struct file_operations capi_fops =
        .write          = capi_write,
        .poll           = capi_poll,
        .unlocked_ioctl = capi_unlocked_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl   = capi_compat_ioctl,
+#endif
        .open           = capi_open,
        .release        = capi_release,
 };