diff options
author | Daniel Scally <djrscally@gmail.com> | 2022-07-07 23:47:32 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-07-15 15:24:40 +0100 |
commit | 1ed3d6446b966143e67a106132eea169b3fc5e1c (patch) | |
tree | b8352d146aa8ecbf48ac0ed1ae266cb9f269ae3f /drivers/media/mc | |
parent | 3193ceeae48ad778a059d66f6ab4299fc498f9d4 (diff) |
media: entity: Add iterator for entity data links
Iterating over the links for an entity is a somewhat common need
through the media subsystem, but generally the assumption is that
they will all be data links. To meet that assumption add a new macro
that iterates through an entity's links and skips non-data links.
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/mc')
-rw-r--r-- | drivers/media/mc/mc-entity.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 11f5207f73aa..a247d5679930 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -9,6 +9,7 @@ */ #include <linux/bitmap.h> +#include <linux/list.h> #include <linux/property.h> #include <linux/slab.h> #include <media/media-entity.h> @@ -1051,3 +1052,18 @@ struct media_link *media_create_ancillary_link(struct media_entity *primary, return link; } EXPORT_SYMBOL_GPL(media_create_ancillary_link); + +struct media_link *__media_entity_next_link(struct media_entity *entity, + struct media_link *link, + unsigned long link_type) +{ + link = link ? list_next_entry(link, list) + : list_first_entry(&entity->links, typeof(*link), list); + + list_for_each_entry_from(link, &entity->links, list) + if ((link->flags & MEDIA_LNK_FL_LINK_TYPE) == link_type) + return link; + + return NULL; +} +EXPORT_SYMBOL_GPL(__media_entity_next_link); |