summaryrefslogtreecommitdiff
path: root/include/media
diff options
context:
space:
mode:
authorDaniel Scally <djrscally@gmail.com>2022-07-07 23:47:32 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-07-15 15:24:40 +0100
commit1ed3d6446b966143e67a106132eea169b3fc5e1c (patch)
treeb8352d146aa8ecbf48ac0ed1ae266cb9f269ae3f /include/media
parent3193ceeae48ad778a059d66f6ab4299fc498f9d4 (diff)
downloadlwn-1ed3d6446b966143e67a106132eea169b3fc5e1c.tar.gz
lwn-1ed3d6446b966143e67a106132eea169b3fc5e1c.zip
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 'include/media')
-rw-r--r--include/media/media-entity.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index a9a1c0ec5d1c..4efe2f88e6dc 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -1140,4 +1140,34 @@ struct media_link *
media_create_ancillary_link(struct media_entity *primary,
struct media_entity *ancillary);
+/**
+ * __media_entity_next_link() - Iterate through a &media_entity's links
+ *
+ * @entity: pointer to the &media_entity
+ * @link: pointer to a &media_link to hold the iterated values
+ * @link_type: one of the MEDIA_LNK_FL_LINK_TYPE flags
+ *
+ * Return the next link against an entity matching a specific link type. This
+ * allows iteration through an entity's links whilst guaranteeing all of the
+ * returned links are of the given type.
+ */
+struct media_link *__media_entity_next_link(struct media_entity *entity,
+ struct media_link *link,
+ unsigned long link_type);
+
+/**
+ * for_each_media_entity_data_link() - Iterate through an entity's data links
+ *
+ * @entity: pointer to the &media_entity
+ * @link: pointer to a &media_link to hold the iterated values
+ *
+ * Iterate over a &media_entity's data links
+ */
+#define for_each_media_entity_data_link(entity, link) \
+ for (link = __media_entity_next_link(entity, NULL, \
+ MEDIA_LNK_FL_DATA_LINK); \
+ link; \
+ link = __media_entity_next_link(entity, link, \
+ MEDIA_LNK_FL_DATA_LINK))
+
#endif