[media] v4l: vsp1: Group all link creation code in a single file
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 31 Jan 2016 13:34:28 +0000 (11:34 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 19 Feb 2016 10:10:38 +0000 (08:10 -0200)
There's no need to spread the code across multiple source files.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/vsp1/vsp1_drv.c
drivers/media/platform/vsp1/vsp1_rpf.c
drivers/media/platform/vsp1/vsp1_rwpf.h
drivers/media/platform/vsp1/vsp1_wpf.c

index 533bc79..d7f6531 100644 (file)
@@ -82,6 +82,19 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
        unsigned int pad;
        int ret;
 
+       if (sink->type == VSP1_ENTITY_RPF) {
+               struct vsp1_rwpf *rpf = to_rwpf(&sink->subdev);
+
+               /* RPFs have no source entities, just connect their source pad
+                * to their video device.
+                */
+               return media_create_pad_link(&rpf->video.video.entity, 0,
+                                            &rpf->entity.subdev.entity,
+                                            RWPF_PAD_SINK,
+                                            MEDIA_LNK_FL_ENABLED |
+                                            MEDIA_LNK_FL_IMMUTABLE);
+       }
+
        list_for_each_entry(source, &vsp1->entities, list_dev) {
                u32 flags;
 
@@ -112,6 +125,23 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
                }
        }
 
+       if (sink->type == VSP1_ENTITY_WPF) {
+               struct vsp1_rwpf *wpf = to_rwpf(&sink->subdev);
+               unsigned int flags = MEDIA_LNK_FL_ENABLED;
+
+               /* Connect the video device to the WPF. All connections are
+                * immutable except for the WPF0 source link if a LIF is
+                * present.
+                */
+               if (!(vsp1->pdata.features & VSP1_HAS_LIF) || sink->index != 0)
+                       flags |= MEDIA_LNK_FL_IMMUTABLE;
+
+               return media_create_pad_link(&wpf->entity.subdev.entity,
+                                            RWPF_PAD_SOURCE,
+                                            &wpf->video.video.entity, 0,
+                                            flags);
+       }
+
        return 0;
 }
 
@@ -256,22 +286,12 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 
        /* Create links. */
        list_for_each_entry(entity, &vsp1->entities, list_dev) {
-               if (entity->type == VSP1_ENTITY_WPF) {
-                       ret = vsp1_wpf_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               } else if (entity->type == VSP1_ENTITY_RPF) {
-                       ret = vsp1_rpf_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               }
+               if (entity->type == VSP1_ENTITY_LIF)
+                       continue;
 
-               if (entity->type != VSP1_ENTITY_LIF &&
-                   entity->type != VSP1_ENTITY_RPF) {
-                       ret = vsp1_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               }
+               ret = vsp1_create_links(vsp1, entity);
+               if (ret < 0)
+                       goto done;
        }
 
        if (vsp1->pdata.features & VSP1_HAS_LIF) {
index 9245382..b988e46 100644 (file)
@@ -283,23 +283,3 @@ error:
        vsp1_entity_destroy(&rpf->entity);
        return ERR_PTR(ret);
 }
-
-/*
- * vsp1_rpf_create_links() - RPF pads links creation
- * @vsp1: Pointer to VSP1 device
- * @entity: Pointer to VSP1 entity
- *
- * return negative error code or zero on success
- */
-int vsp1_rpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity)
-{
-       struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
-
-       /* Connect the video device to the RPF. */
-       return media_create_pad_link(&rpf->video.video.entity, 0,
-                                    &rpf->entity.subdev.entity,
-                                    RWPF_PAD_SINK,
-                                    MEDIA_LNK_FL_ENABLED |
-                                    MEDIA_LNK_FL_IMMUTABLE);
-}
index 731d36e..f452dce 100644 (file)
@@ -50,11 +50,6 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev)
 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
 
-int vsp1_rpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity);
-int vsp1_wpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity);
-
 int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
                             struct v4l2_subdev_pad_config *cfg,
                             struct v4l2_subdev_mbus_code_enum *code);
index cbf514a..1d722f7 100644 (file)
@@ -283,28 +283,3 @@ error:
        vsp1_entity_destroy(&wpf->entity);
        return ERR_PTR(ret);
 }
-
-/*
- * vsp1_wpf_create_links() - RPF pads links creation
- * @vsp1: Pointer to VSP1 device
- * @entity: Pointer to VSP1 entity
- *
- * return negative error code or zero on success
- */
-int vsp1_wpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity)
-{
-       struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev);
-       unsigned int flags;
-
-       /* Connect the video device to the WPF. All connections are immutable
-        * except for the WPF0 source link if a LIF is present.
-        */
-       flags = MEDIA_LNK_FL_ENABLED;
-       if (!(vsp1->pdata.features & VSP1_HAS_LIF) || entity->index != 0)
-               flags |= MEDIA_LNK_FL_IMMUTABLE;
-
-       return media_create_pad_link(&wpf->entity.subdev.entity,
-                                    RWPF_PAD_SOURCE,
-                                    &wpf->video.video.entity, 0, flags);
-}