[RFC,1/3] media: videobuf2: WARN if !vb2_queue.buf_ops
Commit Message
The videobuf2 framework unconditionally set 'struct vb2_queue.buf_ops'
to 'v4l2_buf_ops' in vb2_queue_init_name() and does not allow drivers to
overwrite it.
The framework then assumes all 'buf_ops' operations to be present and
valid.
To prepare for allowing drivers to override the 'buf_ops' members
implementation but still guarantee all members are correctly populated
and valid, WARN() if any of the 'buf_ops' operations is not available in
the function call wrappers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/common/videobuf2/videobuf2-core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
@@ -187,15 +187,19 @@ module_param(debug, int, 0644);
#define call_bufop(q, op, args...) \
({ \
int ret = 0; \
- if (q && q->buf_ops && q->buf_ops->op) \
- ret = q->buf_ops->op(args); \
+ if (q) { \
+ if (!WARN_ON(!q->buf_ops) && !WARN_ON(!q->buf_ops->op)) \
+ ret = q->buf_ops->op(args); \
+ } \
ret; \
})
#define call_void_bufop(q, op, args...) \
({ \
- if (q && q->buf_ops && q->buf_ops->op) \
- q->buf_ops->op(args); \
+ if (q) { \
+ if (!WARN_ON(!q->buf_ops) && !WARN_ON(!q->buf_ops->op)) \
+ q->buf_ops->op(args); \
+ } \
})
static void __vb2_queue_cancel(struct vb2_queue *q);