From: Mauro Carvalho Chehab Date: Mon, 24 Aug 2015 11:46:46 +0000 (-0300) Subject: [media] media-entity: unregister entity links X-Git-Tag: v4.14-rc1~4034^2~116 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c4696a910d404eda3477e76a35c155a6b83ca3e;p=platform%2Fkernel%2Flinux-rpi.git [media] media-entity: unregister entity links Add functions to explicitly unregister all entity links. This function is called automatically when an entity link is destroyed. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 1b2fd72..ceae708 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -891,6 +891,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { + media_remove_intf_links(&devnode->intf); media_gobj_remove(&devnode->intf.graph_obj); kfree(devnode); } @@ -932,3 +933,25 @@ void media_remove_intf_link(struct media_link *link) mutex_unlock(&link->graph_obj.mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_remove_intf_link); + +void __media_remove_intf_links(struct media_interface *intf) +{ + struct media_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, &intf->links, list) + __media_remove_intf_link(link); + +} +EXPORT_SYMBOL_GPL(__media_remove_intf_links); + +void media_remove_intf_links(struct media_interface *intf) +{ + /* Do nothing if the intf is not registered. */ + if (intf->graph_obj.mdev == NULL) + return; + + mutex_lock(&intf->graph_obj.mdev->graph_mutex); + __media_remove_intf_links(intf); + mutex_unlock(&intf->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_remove_intf_links); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index f905860..0753f30 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -326,6 +326,9 @@ struct media_link *media_create_intf_link(struct media_entity *entity, struct media_interface *intf, u32 flags); void media_remove_intf_link(struct media_link *link); +void __media_remove_intf_links(struct media_interface *intf); +void media_remove_intf_links(struct media_interface *intf); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \