diff mbox

[RFC,v2,04/16] media: ensure that entities will have an object ID

Message ID c65da4024cbf92a2a87be387b86a456688ed7380.1438954897.git.mchehab@osg.samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Aug. 7, 2015, 2:20 p.m. UTC
All objects need an object ID. However, as v4l2 subdevs embeed
entities internally, the code needs to manually check if the
entity objects were not properly initialized and do it at
entity register time.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff mbox

Patch

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index e627b0b905ad..960a4e30c68d 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -435,6 +435,13 @@  int __must_check media_device_register_entity(struct media_device *mdev,
 	entity->parent = mdev;
 
 	spin_lock(&mdev->lock);
+	/* Initialize media_graph_obj embedded at the entity */
+	graph_obj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
+
+	/*
+	 * FIXME: should it use the unique object ID or would it
+	 * break support on the legacy MC API?
+	 */
 	if (entity->id == 0)
 		entity->id = mdev->entity_id++;
 	else
@@ -461,6 +468,7 @@  void media_device_unregister_entity(struct media_entity *entity)
 		return;
 
 	spin_lock(&mdev->lock);
+	graph_obj_remove(&entity->graph_obj);
 	list_del(&entity->list);
 	spin_unlock(&mdev->lock);
 	entity->parent = NULL;