[media] media-device: remove interfaces and interface links
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sun, 30 Aug 2015 00:23:44 +0000 (21:23 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:18:55 +0000 (12:18 -0200)
Just like what's done with entities, when the media controller is
unregistered, release any interface and interface links that
might still be there.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-device.c
drivers/media/media-entity.c
include/media/media-entity.h

index 7c37aeab05bbdf6e5bea802fc9fc25a49e2ce83b..96700843b1e4f089b21887439153362992acff29 100644 (file)
@@ -574,6 +574,17 @@ void media_device_unregister(struct media_device *mdev)
 {
        struct media_entity *entity;
        struct media_entity *next;
+       struct media_interface *intf, *tmp_intf;
+
+       /* Remove all interfaces from the media device */
+       spin_lock(&mdev->lock);
+       list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces,
+                                graph_obj.list) {
+               __media_remove_intf_links(intf);
+               media_gobj_remove(&intf->graph_obj);
+               kfree(intf);
+       }
+       spin_unlock(&mdev->lock);
 
        list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
                media_device_unregister_entity(entity);
@@ -633,27 +644,24 @@ void media_device_unregister_entity(struct media_entity *entity)
        int i;
        struct media_device *mdev = entity->graph_obj.mdev;
        struct media_link *link, *tmp;
+       struct media_interface *intf;
 
        if (mdev == NULL)
                return;
 
        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 interface links pointing to this entity */
+       list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) {
+               list_for_each_entry_safe(link, tmp, &intf->links, list) {
+                       if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY
+                           && link->entity == entity)
+                               __media_remove_intf_link(link);
                }
        }
 
        /* Remove all data links that belong to this entity */
-       list_for_each_entry_safe(link, tmp, &entity->links, list) {
-               media_gobj_remove(&link->graph_obj);
-               list_del(&link->list);
-               kfree(link);
-       }
+       __media_entity_remove_links(entity);
 
        /* Remove all pads that belong to this entity */
        for (i = 0; i < entity->num_pads; i++)
index ceae708bdad49eade661f6a6f633aa68282bdff6..ee0f81364960868f2763ac360a0b781f8a164eaa 100644 (file)
@@ -674,9 +674,11 @@ static void __media_entity_remove_link(struct media_entity *entity,
 
                /* Remove the remote link */
                list_del(&rlink->list);
+               media_gobj_remove(&rlink->graph_obj);
                kfree(rlink);
        }
        list_del(&link->list);
+       media_gobj_remove(&link->graph_obj);
        kfree(link);
 }
 
@@ -920,11 +922,13 @@ struct media_link *media_create_intf_link(struct media_entity *entity,
 EXPORT_SYMBOL_GPL(media_create_intf_link);
 
 
-static void __media_remove_intf_link(struct media_link *link)
+void __media_remove_intf_link(struct media_link *link)
 {
+       list_del(&link->list);
        media_gobj_remove(&link->graph_obj);
        kfree(link);
 }
+EXPORT_SYMBOL_GPL(__media_remove_intf_link);
 
 void media_remove_intf_link(struct media_link *link)
 {
index 0753f3029d063da0d2130c9c10df7f63d7f25dbb..f165d303f03c896fb7244947708da920007366b2 100644 (file)
@@ -325,6 +325,7 @@ void media_devnode_remove(struct media_intf_devnode *devnode);
 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_link(struct media_link *link);
 void __media_remove_intf_links(struct media_interface *intf);
 void media_remove_intf_links(struct media_interface *intf);
This page took 0.038812 seconds and 5 git commands to generate.