]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[media] uvcvideo: register entity subdev on init
authorJavier Martinez Canillas <javier@osg.samsung.com>
Fri, 11 Dec 2015 17:16:35 +0000 (15:16 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:09 +0000 (12:19 -0200)
The uvc_mc_register_entities() function iterated over the entities three
times to initialize the entities, register the subdev for the ones whose
type was UVC_TT_STREAMING and to create the entities links.

But this can be simplied by merging the init and registration logic in a
single loop.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/uvc/uvc_entity.c

index 33119dcb7ceccf9e13607f4509fad28a867d42b6..ac386bb547e6e305c77fbba21d980d0c83a20ffe 100644 (file)
 
 #include "uvcvideo.h"
 
-/* ------------------------------------------------------------------------
- * Video subdevices registration and unregistration
- */
-
-static int uvc_mc_register_entity(struct uvc_video_chain *chain,
-       struct uvc_entity *entity)
-{
-       if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING)
-               return 0;
-
-       return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev);
-}
-
 static int uvc_mc_create_links(struct uvc_video_chain *chain,
                                    struct uvc_entity *entity)
 {
@@ -85,7 +72,8 @@ void uvc_mc_cleanup_entity(struct uvc_entity *entity)
                media_entity_cleanup(&entity->vdev->entity);
 }
 
-static int uvc_mc_init_entity(struct uvc_entity *entity)
+static int uvc_mc_init_entity(struct uvc_video_chain *chain,
+                             struct uvc_entity *entity)
 {
        int ret;
 
@@ -96,6 +84,12 @@ static int uvc_mc_init_entity(struct uvc_entity *entity)
 
                ret = media_entity_pads_init(&entity->subdev.entity,
                                        entity->num_pads, entity->pads);
+
+               if (ret < 0)
+                       return ret;
+
+               ret = v4l2_device_register_subdev(&chain->dev->vdev,
+                                                 &entity->subdev);
        } else if (entity->vdev != NULL) {
                ret = media_entity_pads_init(&entity->vdev->entity,
                                        entity->num_pads, entity->pads);
@@ -113,7 +107,7 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
        int ret;
 
        list_for_each_entry(entity, &chain->entities, chain) {
-               ret = uvc_mc_init_entity(entity);
+               ret = uvc_mc_init_entity(chain, entity);
                if (ret < 0) {
                        uvc_printk(KERN_INFO, "Failed to initialize entity for "
                                   "entity %u\n", entity->id);
@@ -121,15 +115,6 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
                }
        }
 
-       list_for_each_entry(entity, &chain->entities, chain) {
-               ret = uvc_mc_register_entity(chain, entity);
-               if (ret < 0) {
-                       uvc_printk(KERN_INFO, "Failed to register entity for "
-                                  "entity %u\n", entity->id);
-                       return ret;
-               }
-       }
-
        list_for_each_entry(entity, &chain->entities, chain) {
                ret = uvc_mc_create_links(chain, entity);
                if (ret < 0) {