INIT_LIST_HEAD(&mdev->entities);
INIT_LIST_HEAD(&mdev->interfaces);
+ INIT_LIST_HEAD(&mdev->pads);
+ INIT_LIST_HEAD(&mdev->links);
spin_lock_init(&mdev->lock);
mutex_init(&mdev->graph_mutex);
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);
*/
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);
}
/**
* @intf_devnode_id: Unique ID used on the last interface devnode registered
* @entities: List of registered entities
* @interfaces: List of registered interfaces
+ * @pads: List of registered pads
+ * @links: List of registered links
* @lock: Entities list lock
* @graph_mutex: Entities graph operation lock
* @link_notify: Link state change notification callback
struct list_head entities;
struct list_head interfaces;
+ struct list_head pads;
+ struct list_head links;
/* Protects the entities list */
spinlock_t lock;
#define media_device_for_each_intf(intf, mdev) \
list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)
+/* Iterate over all pads. */
+#define media_device_for_each_pad(pad, mdev) \
+ list_for_each_entry(pad, &(mdev)->pads, graph_obj.list)
+
+/* Iterate over all links. */
+#define media_device_for_each_link(link, mdev) \
+ list_for_each_entry(link, &(mdev)->links, graph_obj.list)
+
#else
static inline int media_device_register(struct media_device *mdev)