From 9155d859b6bec29cdbbd80a509be35de55115f00 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 08:00:33 -0300 Subject: [media] media-device: add pads and links to media_device The MC next gen API sends objects to userspace grouped by their types. In the case of pads and links, in order to improve performance and have a simpler code, the best is to store them also on separate linked lists at MC. If we don't do that, we would need this kind of interaction to send data to userspace (code is in structured english): for each entity: for each pad: store pads for each entity: for each link: store link for each interface: for each link: store link With would require one nested loop for pads and two nested loops for links. By using separate linked lists for them, just one loop would be enough. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers/media/media-entity.c') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index b3875b0185c1..2f3d3aae20a7 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -162,13 +162,15 @@ void media_gobj_init(struct media_device *mdev, break; case MEDIA_GRAPH_PAD: gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); + list_add_tail(&gobj->list, &mdev->pads); break; case MEDIA_GRAPH_LINK: gobj->id = media_gobj_gen_id(type, ++mdev->link_id); + list_add_tail(&gobj->list, &mdev->links); break; case MEDIA_GRAPH_INTF_DEVNODE: - list_add_tail(&gobj->list, &mdev->interfaces); gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); + list_add_tail(&gobj->list, &mdev->interfaces); break; } dev_dbg_obj(__func__, gobj); @@ -183,17 +185,10 @@ void media_gobj_init(struct media_device *mdev, */ void media_gobj_remove(struct media_gobj *gobj) { - /* Remove the object from mdev list */ - switch (media_type(gobj)) { - case MEDIA_GRAPH_ENTITY: - case MEDIA_GRAPH_INTF_DEVNODE: - list_del(&gobj->list); - break; - default: - break; - } - dev_dbg_obj(__func__, gobj); + + /* Remove the object from mdev list */ + list_del(&gobj->list); } /** -- cgit v1.2.3