Commit a28971ad authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] remove interface links at media_entity_unregister()

Interface links connected to an entity should be removed
before the entity itself can be removed.
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 7c4696a9
...@@ -638,14 +638,30 @@ void media_device_unregister_entity(struct media_entity *entity) ...@@ -638,14 +638,30 @@ void media_device_unregister_entity(struct media_entity *entity)
return; return;
spin_lock(&mdev->lock); spin_lock(&mdev->lock);
/* Remove interface links with this entity on it */
list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) {
if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY
&& link->entity == entity) {
media_gobj_remove(&link->graph_obj);
kfree(link);
}
}
/* Remove all data links that belong to this entity */
list_for_each_entry_safe(link, tmp, &entity->links, list) { list_for_each_entry_safe(link, tmp, &entity->links, list) {
media_gobj_remove(&link->graph_obj); media_gobj_remove(&link->graph_obj);
list_del(&link->list); list_del(&link->list);
kfree(link); kfree(link);
} }
/* Remove all pads that belong to this entity */
for (i = 0; i < entity->num_pads; i++) for (i = 0; i < entity->num_pads; i++)
media_gobj_remove(&entity->pads[i].graph_obj); media_gobj_remove(&entity->pads[i].graph_obj);
/* Remove the entity */
media_gobj_remove(&entity->graph_obj); media_gobj_remove(&entity->graph_obj);
spin_unlock(&mdev->lock); spin_unlock(&mdev->lock);
entity->graph_obj.mdev = NULL; entity->graph_obj.mdev = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment