]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: videobuf2: check constants during build time
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Fri, 28 Mar 2025 22:05:27 +0000 (23:05 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 25 Apr 2025 13:14:29 +0000 (15:14 +0200)
There is nothing a driver author can do fix in the driver to make the
global constants match. Since the assertion can be verified at build
time, don't return EINVAL at runtime for it.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/common/videobuf2/videobuf2-v4l2.c

index 9201d854dbcc0c745c56798afcce1afd78a62b5f..1cd26faee50338aefeb670c6865da7c2d43f44d3 100644 (file)
@@ -903,6 +903,11 @@ EXPORT_SYMBOL_GPL(vb2_expbuf);
 
 int vb2_queue_init_name(struct vb2_queue *q, const char *name)
 {
+       /* vb2_memory should match with v4l2_memory */
+       BUILD_BUG_ON(VB2_MEMORY_MMAP != (int)V4L2_MEMORY_MMAP);
+       BUILD_BUG_ON(VB2_MEMORY_USERPTR != (int)V4L2_MEMORY_USERPTR);
+       BUILD_BUG_ON(VB2_MEMORY_DMABUF != (int)V4L2_MEMORY_DMABUF);
+
        /*
         * Sanity check
         */
@@ -916,12 +921,6 @@ int vb2_queue_init_name(struct vb2_queue *q, const char *name)
        WARN_ON((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
                V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
 
-       /* Warn that vb2_memory should match with v4l2_memory */
-       if (WARN_ON(VB2_MEMORY_MMAP != (int)V4L2_MEMORY_MMAP)
-               || WARN_ON(VB2_MEMORY_USERPTR != (int)V4L2_MEMORY_USERPTR)
-               || WARN_ON(VB2_MEMORY_DMABUF != (int)V4L2_MEMORY_DMABUF))
-               return -EINVAL;
-
        if (q->buf_struct_size == 0)
                q->buf_struct_size = sizeof(struct vb2_v4l2_buffer);