media: videobuf2-v4l2: replace if by switch in __fill_vb2_buffer()
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 14 Aug 2018 09:29:40 +0000 (05:29 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 31 Aug 2018 15:13:52 +0000 (11:13 -0400)
Replace 'if' statements by a switch in __fill_vb2_buffer()
in preparation of the next patch.

No other changes.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/common/videobuf2/videobuf2-v4l2.c

index 408fd7c..57848dd 100644 (file)
@@ -190,21 +190,25 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
        vbuf->sequence = 0;
 
        if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
-               if (b->memory == VB2_MEMORY_USERPTR) {
+               switch (b->memory) {
+               case VB2_MEMORY_USERPTR:
                        for (plane = 0; plane < vb->num_planes; ++plane) {
                                planes[plane].m.userptr =
                                        b->m.planes[plane].m.userptr;
                                planes[plane].length =
                                        b->m.planes[plane].length;
                        }
-               }
-               if (b->memory == VB2_MEMORY_DMABUF) {
+                       break;
+               case VB2_MEMORY_DMABUF:
                        for (plane = 0; plane < vb->num_planes; ++plane) {
                                planes[plane].m.fd =
                                        b->m.planes[plane].m.fd;
                                planes[plane].length =
                                        b->m.planes[plane].length;
                        }
+                       break;
+               default:
+                       break;
                }
 
                /* Fill in driver-provided information for OUTPUT types */
@@ -255,14 +259,17 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
                 * the driver should use the allow_zero_bytesused flag to keep
                 * old userspace applications working.
                 */
-               if (b->memory == VB2_MEMORY_USERPTR) {
+               switch (b->memory) {
+               case VB2_MEMORY_USERPTR:
                        planes[0].m.userptr = b->m.userptr;
                        planes[0].length = b->length;
-               }
-
-               if (b->memory == VB2_MEMORY_DMABUF) {
+                       break;
+               case VB2_MEMORY_DMABUF:
                        planes[0].m.fd = b->m.fd;
                        planes[0].length = b->length;
+                       break;
+               default:
+                       break;
                }
 
                if (V4L2_TYPE_IS_OUTPUT(b->type)) {