]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] media: Amend media graph walk API by init and cleanup functions
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 16 Dec 2015 13:32:22 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:18 +0000 (12:19 -0200)
Add media_entity_graph_walk_init() and media_entity_graph_walk_cleanup()
functions in order to dynamically allocate memory for the graph. This is
not done in media_entity_graph_walk_start() as there are situations where
e.g. correct error handling, that itself may not fail, requires successful
graph walk.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-entity.c
include/media/media-entity.h

index 83cfde6dcb1ca1f50d9e9085112551c6acc19b31..9bf96c71374ee500dcb86a7a5a87e2839b6a60c4 100644 (file)
@@ -282,6 +282,33 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
 #define link_top(en)   ((en)->stack[(en)->top].link)
 #define stack_top(en)  ((en)->stack[(en)->top].entity)
 
+/**
+ * media_entity_graph_walk_init - Allocate resources for graph walk
+ * @graph: Media graph structure that will be used to walk the graph
+ * @mdev: Media device
+ *
+ * Reserve resources for graph walk in media device's current
+ * state. The memory must be released using
+ * media_entity_graph_walk_free().
+ *
+ * Returns error on failure, zero on success.
+ */
+__must_check int media_entity_graph_walk_init(
+       struct media_entity_graph *graph, struct media_device *mdev)
+{
+       return 0;
+}
+EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
+
+/**
+ * media_entity_graph_walk_cleanup - Release resources related to graph walking
+ * @graph: Media graph structure that was used to walk the graph
+ */
+void media_entity_graph_walk_cleanup(struct media_entity_graph *graph)
+{
+}
+EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
+
 void media_entity_graph_walk_start(struct media_entity_graph *graph,
                                   struct media_entity *entity)
 {
index 4dc3bef72c9dbccc750ba0b06de544cb77c6ef4c..7f028ea84911846e06c4d6c51d066f8a261c35da 100644 (file)
@@ -699,6 +699,10 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
  */
 struct media_entity *media_entity_get(struct media_entity *entity);
 
+__must_check int media_entity_graph_walk_init(
+       struct media_entity_graph *graph, struct media_device *mdev);
+void media_entity_graph_walk_cleanup(struct media_entity_graph *graph);
+
 /**
  * media_entity_put - Release the reference to the parent module
  *
@@ -715,13 +719,16 @@ void media_entity_put(struct media_entity *entity);
  * @graph: Media graph structure that will be used to walk the graph
  * @entity: Starting entity
  *
- * This function initializes the graph traversal structure to walk the entities
- * graph starting at the given entity. The traversal structure must not be
- * modified by the caller during graph traversal. When done the structure can
- * safely be freed.
+ * Before using this function, media_entity_graph_walk_init() must be
+ * used to allocate resources used for walking the graph. This
+ * function initializes the graph traversal structure to walk the
+ * entities graph starting at the given entity. The traversal
+ * structure must not be modified by the caller during graph
+ * traversal. After the graph walk, the resources must be released
+ * using media_entity_graph_walk_cleanup().
  */
 void media_entity_graph_walk_start(struct media_entity_graph *graph,
-               struct media_entity *entity);
+                                  struct media_entity *entity);
 
 /**
  * media_entity_graph_walk_next - Get the next entity in the graph