* [PATCH] media: videobuf2: check constants during build time
@ 2025-03-28 22:05 ` Michał Mirosław
2025-04-02 7:58 ` Marek Szyprowski
0 siblings, 1 reply; 2+ messages in thread
From: Michał Mirosław @ 2025-03-28 22:05 UTC (permalink / raw)
To: Tomasz Figa, Marek Szyprowski
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel
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>
---
drivers/media/common/videobuf2/videobuf2-v4l2.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 9201d854dbcc..1cd26faee503 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -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);
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] media: videobuf2: check constants during build time
2025-03-28 22:05 ` [PATCH] media: videobuf2: check constants during build time Michał Mirosław
@ 2025-04-02 7:58 ` Marek Szyprowski
0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2025-04-02 7:58 UTC (permalink / raw)
To: Michał Mirosław, Tomasz Figa
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel
On 28.03.2025 23:05, Michał Mirosław wrote:
> 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>
> ---
> drivers/media/common/videobuf2/videobuf2-v4l2.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 9201d854dbcc..1cd26faee503 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -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);
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-02 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20250328220534eucas1p1cc5c334505d06f34a4eb01b8c1df27da@eucas1p1.samsung.com>
2025-03-28 22:05 ` [PATCH] media: videobuf2: check constants during build time Michał Mirosław
2025-04-02 7:58 ` Marek Szyprowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®