[media] uvcvideo: (cosmetic) Add and use an inline function
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Mon, 12 Dec 2016 11:16:49 +0000 (09:16 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 31 Jan 2017 12:53:56 +0000 (10:53 -0200)
Add an inline function to obtain a struct uvc_buffer pointer from a
struct vb2_v4l2_buffer one.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/usb/uvc/uvc_queue.c

index 77edd206d3452b71460326e970a62c10b62708df..0cc7ae23604dac0a939ffe7b5ed19d5bb9d8f150 100644 (file)
@@ -43,6 +43,11 @@ uvc_queue_to_stream(struct uvc_video_queue *queue)
        return container_of(queue, struct uvc_streaming, queue);
 }
 
+static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf)
+{
+       return container_of(buf, struct uvc_buffer, buf);
+}
+
 /*
  * Return all queued buffers to videobuf2 in the requested state.
  *
@@ -89,7 +94,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
-       struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf);
+       struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
 
        if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
            vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
@@ -116,7 +121,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
-       struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf);
+       struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
        unsigned long flags;
 
        spin_lock_irqsave(&queue->irqlock, flags);
@@ -138,7 +143,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
        struct uvc_streaming *stream = uvc_queue_to_stream(queue);
-       struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf);
+       struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
 
        if (vb->state == VB2_BUF_STATE_DONE)
                uvc_video_clock_update(stream, vbuf, buf);