summaryrefslogtreecommitdiff
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-08-14 18:50:08 +0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-01-11 17:18:42 +0300
commit18710dc67a433ed2c3ecaaffefd8e34502e53262 (patch)
tree641ab8210e297bb165a53536035d23d3e1df7dd5 /drivers/media/media-device.c
parentbfab2aacccfc144e2cceccb71ec89f1eff1b8c51 (diff)
downloadlinux-18710dc67a433ed2c3ecaaffefd8e34502e53262.tar.xz
[media] media: use media_gobj inside pads
PADs also need unique object IDs that won't conflict with the entity object IDs. The pad objects are currently created via media_entity_init() and, once created, never change. While this will likely change in the future in order to support dynamic changes, for now we'll keep PADs as arrays and initialize the media_gobj embedded structs when registering the entity. Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r--drivers/media/media-device.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 81d6a130efef..3bdda16584fe 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -427,6 +427,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
int __must_check media_device_register_entity(struct media_device *mdev,
struct media_entity *entity)
{
+ int i;
+
/* Warn if we apparently re-register an entity */
WARN_ON(entity->parent != NULL);
entity->parent = mdev;
@@ -435,6 +437,12 @@ int __must_check media_device_register_entity(struct media_device *mdev,
/* Initialize media_gobj embedded at the entity */
media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
list_add_tail(&entity->list, &mdev->entities);
+
+ /* Initialize objects at the pads */
+ for (i = 0; i < entity->num_pads; i++)
+ media_gobj_init(mdev, MEDIA_GRAPH_PAD,
+ &entity->pads[i].graph_obj);
+
spin_unlock(&mdev->lock);
return 0;
@@ -450,12 +458,15 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
*/
void media_device_unregister_entity(struct media_entity *entity)
{
+ int i;
struct media_device *mdev = entity->parent;
if (mdev == NULL)
return;
spin_lock(&mdev->lock);
+ for (i = 0; i < entity->num_pads; i++)
+ media_gobj_remove(&entity->pads[i].graph_obj);
media_gobj_remove(&entity->graph_obj);
list_del(&entity->list);
spin_unlock(&mdev->lock);