Commit 05bfa9fa authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] media: move mdev list init to gobj

Let's control the topology changes inside the graph_object. So, move the
addition and removal of interfaces/entities from the mdev lists to
media_gobj_init() and media_gobj_remove().

The main reason is that mdev should have lists for all object types, as
the new MC api will require to store objects in separate places.
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent cf975a4b
...@@ -415,7 +415,7 @@ void media_device_unregister(struct media_device *mdev) ...@@ -415,7 +415,7 @@ void media_device_unregister(struct media_device *mdev)
struct media_entity *entity; struct media_entity *entity;
struct media_entity *next; struct media_entity *next;
list_for_each_entry_safe(entity, next, &mdev->entities, list) list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
media_device_unregister_entity(entity); media_device_unregister_entity(entity);
device_remove_file(&mdev->devnode.dev, &dev_attr_model); device_remove_file(&mdev->devnode.dev, &dev_attr_model);
...@@ -449,7 +449,6 @@ int __must_check media_device_register_entity(struct media_device *mdev, ...@@ -449,7 +449,6 @@ int __must_check media_device_register_entity(struct media_device *mdev,
spin_lock(&mdev->lock); spin_lock(&mdev->lock);
/* Initialize media_gobj embedded at the entity */ /* Initialize media_gobj embedded at the entity */
media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
list_add_tail(&entity->list, &mdev->entities);
/* Initialize objects at the pads */ /* Initialize objects at the pads */
for (i = 0; i < entity->num_pads; i++) for (i = 0; i < entity->num_pads; i++)
...@@ -487,7 +486,6 @@ void media_device_unregister_entity(struct media_entity *entity) ...@@ -487,7 +486,6 @@ void media_device_unregister_entity(struct media_entity *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);
media_gobj_remove(&entity->graph_obj); media_gobj_remove(&entity->graph_obj);
list_del(&entity->list);
spin_unlock(&mdev->lock); spin_unlock(&mdev->lock);
entity->graph_obj.mdev = NULL; entity->graph_obj.mdev = NULL;
} }
......
...@@ -158,6 +158,7 @@ void media_gobj_init(struct media_device *mdev, ...@@ -158,6 +158,7 @@ void media_gobj_init(struct media_device *mdev,
switch (type) { switch (type) {
case MEDIA_GRAPH_ENTITY: case MEDIA_GRAPH_ENTITY:
gobj->id = media_gobj_gen_id(type, ++mdev->entity_id); gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
list_add_tail(&gobj->list, &mdev->entities);
break; break;
case MEDIA_GRAPH_PAD: case MEDIA_GRAPH_PAD:
gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
...@@ -166,6 +167,7 @@ void media_gobj_init(struct media_device *mdev, ...@@ -166,6 +167,7 @@ void media_gobj_init(struct media_device *mdev,
gobj->id = media_gobj_gen_id(type, ++mdev->link_id); gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
break; break;
case MEDIA_GRAPH_INTF_DEVNODE: case MEDIA_GRAPH_INTF_DEVNODE:
list_add_tail(&gobj->list, &mdev->interfaces);
gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
break; break;
} }
...@@ -181,6 +183,16 @@ void media_gobj_init(struct media_device *mdev, ...@@ -181,6 +183,16 @@ void media_gobj_init(struct media_device *mdev,
*/ */
void media_gobj_remove(struct media_gobj *gobj) 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); dev_dbg_obj(__func__, gobj);
} }
...@@ -852,8 +864,6 @@ static void media_interface_init(struct media_device *mdev, ...@@ -852,8 +864,6 @@ static void media_interface_init(struct media_device *mdev,
INIT_LIST_HEAD(&intf->links); INIT_LIST_HEAD(&intf->links);
media_gobj_init(mdev, gobj_type, &intf->graph_obj); media_gobj_init(mdev, gobj_type, &intf->graph_obj);
list_add_tail(&intf->list, &mdev->interfaces);
} }
/* Functions related to the media interface via device nodes */ /* Functions related to the media interface via device nodes */
...@@ -882,7 +892,6 @@ EXPORT_SYMBOL_GPL(media_devnode_create); ...@@ -882,7 +892,6 @@ EXPORT_SYMBOL_GPL(media_devnode_create);
void media_devnode_remove(struct media_intf_devnode *devnode) void media_devnode_remove(struct media_intf_devnode *devnode)
{ {
media_gobj_remove(&devnode->intf.graph_obj); media_gobj_remove(&devnode->intf.graph_obj);
list_del(&devnode->intf.list);
kfree(devnode); kfree(devnode);
} }
EXPORT_SYMBOL_GPL(media_devnode_remove); EXPORT_SYMBOL_GPL(media_devnode_remove);
......
...@@ -111,11 +111,11 @@ struct media_device *media_device_find_devres(struct device *dev); ...@@ -111,11 +111,11 @@ struct media_device *media_device_find_devres(struct device *dev);
/* Iterate over all entities. */ /* Iterate over all entities. */
#define media_device_for_each_entity(entity, mdev) \ #define media_device_for_each_entity(entity, mdev) \
list_for_each_entry(entity, &(mdev)->entities, list) list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)
/* Iterate over all interfaces. */ /* Iterate over all interfaces. */
#define media_device_for_each_intf(intf, mdev) \ #define media_device_for_each_intf(intf, mdev) \
list_for_each_entry(intf, &(mdev)->interfaces, list) list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)
#else #else
......
...@@ -66,6 +66,7 @@ enum media_gobj_type { ...@@ -66,6 +66,7 @@ enum media_gobj_type {
struct media_gobj { struct media_gobj {
struct media_device *mdev; struct media_device *mdev;
u32 id; u32 id;
struct list_head list;
}; };
...@@ -114,7 +115,6 @@ struct media_entity_operations { ...@@ -114,7 +115,6 @@ struct media_entity_operations {
struct media_entity { struct media_entity {
struct media_gobj graph_obj; /* must be first field in struct */ struct media_gobj graph_obj; /* must be first field in struct */
struct list_head list;
const char *name; /* Entity name */ const char *name; /* Entity name */
u32 type; /* Entity type (MEDIA_ENT_T_*) */ u32 type; /* Entity type (MEDIA_ENT_T_*) */
u32 revision; /* Entity revision, driver specific */ u32 revision; /* Entity revision, driver specific */
...@@ -166,7 +166,6 @@ struct media_entity { ...@@ -166,7 +166,6 @@ struct media_entity {
*/ */
struct media_interface { struct media_interface {
struct media_gobj graph_obj; struct media_gobj graph_obj;
struct list_head list;
struct list_head links; struct list_head links;
u32 type; u32 type;
u32 flags; u32 flags;
......
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