Merge tag 'media/v6.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[sfrench/cifs-2.6.git] / drivers / media / v4l2-core / v4l2-ioctl.c
index 2a0139c72d29bd4bae7d137c1f01843f06f81c39..87f163a89c80503a9d28c45cce499302d84a6f8a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/version.h>
 
+#include <linux/v4l2-subdev.h>
 #include <linux/videodev2.h>
 
 #include <media/media-device.h> /* for media_set_bus_info() */
@@ -3154,6 +3155,21 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
                ret = 1;
                break;
        }
+
+       case VIDIOC_SUBDEV_G_ROUTING:
+       case VIDIOC_SUBDEV_S_ROUTING: {
+               struct v4l2_subdev_routing *routing = parg;
+
+               if (routing->num_routes > 256)
+                       return -E2BIG;
+
+               *user_ptr = u64_to_user_ptr(routing->routes);
+               *kernel_ptr = (void **)&routing->routes;
+               *array_size = sizeof(struct v4l2_subdev_route)
+                           * routing->num_routes;
+               ret = 1;
+               break;
+       }
        }
 
        return ret;
@@ -3400,8 +3416,15 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
        /*
         * Some ioctls can return an error, but still have valid
         * results that must be returned.
+        *
+        * FIXME: subdev IOCTLS are partially handled here and partially in
+        * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS
+        * defined here as part of the 'v4l2_ioctls' array. As
+        * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even
+        * in case of failure, but it is not defined here as part of the
+        * 'v4l2_ioctls' array, insert an ad-hoc check to address that.
         */
-       if (err < 0 && !always_copy)
+       if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING)
                goto out;
 
        if (has_array_args) {