]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
V4L/DVB: video_ioctl2: handle the v4l1 compat bit first and move VIDIOCGMBUF into...
authorHans Verkuil <hverkuil@xs4all.nl>
Tue, 6 Apr 2010 18:56:08 +0000 (15:56 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:57:10 +0000 (12:57 -0300)
Try to make a more sensible sequence of events in __video_do_ioctl: first
check for a valid ops pointer, then get the compat part done. The VIDIOCGMBUF
command is now part of the big switch.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-ioctl.c

index 571f0c6e7c834c1344bfc87dd3d6f41fbf7df5f1..3da8d8f041d8440780b19d7416e5dfd3c9f22898 100644 (file)
@@ -610,17 +610,33 @@ static long __video_do_ioctl(struct file *file,
        void *fh = file->private_data;
        long ret = -EINVAL;
 
+       if (ops == NULL) {
+               printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n",
+                               vfd->name);
+               return -EINVAL;
+       }
+
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
+       /********************************************************
+        All other V4L1 calls are handled by v4l1_compat module.
+        Those calls will be translated into V4L2 calls, and
+        __video_do_ioctl will be called again, with one or more
+        V4L2 ioctls.
+        ********************************************************/
+       if (_IOC_TYPE(cmd) == 'v' && cmd != VIDIOCGMBUF &&
+                               _IOC_NR(cmd) < BASE_VIDIOCPRIVATE) {
+               return v4l_compat_translate_ioctl(file, cmd, arg,
+                                               __video_do_ioctl);
+       }
+#endif
+
        if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
                                !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
                v4l_print_ioctl(vfd->name, cmd);
                printk(KERN_CONT "\n");
        }
 
-       if (ops == NULL) {
-               printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n",
-                               vfd->name);
-               return -EINVAL;
-       }
+       switch (cmd) {
 
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
        /***********************************************************
@@ -630,31 +646,21 @@ static long __video_do_ioctl(struct file *file,
         ***********************************************************/
 
        /* --- streaming capture ------------------------------------- */
-       if (cmd == VIDIOCGMBUF) {
+       case VIDIOCGMBUF:
+       {
                struct video_mbuf *p = arg;
 
                if (!ops->vidiocgmbuf)
-                       return ret;
+                       break;
                ret = ops->vidiocgmbuf(file, fh, p);
                if (!ret)
                        dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
                                                p->size, p->frames,
                                                (unsigned long)p->offsets);
-               return ret;
+               break;
        }
-
-       /********************************************************
-        All other V4L1 calls are handled by v4l1_compat module.
-        Those calls will be translated into V4L2 calls, and
-        __video_do_ioctl will be called again, with one or more
-        V4L2 ioctls.
-        ********************************************************/
-       if (_IOC_TYPE(cmd) == 'v' && _IOC_NR(cmd) < BASE_VIDIOCPRIVATE)
-               return v4l_compat_translate_ioctl(file, cmd, arg,
-                                               __video_do_ioctl);
 #endif
 
-       switch (cmd) {
        /* --- capabilities ------------------------------------------ */
        case VIDIOC_QUERYCAP:
        {