]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
[media] media: Use entity enums in graph walk
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 16 Dec 2015 13:32:28 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:20 +0000 (12:19 -0200)
This will also mean that the necessary graph related data structures will
be allocated dynamically, removing the need for maximum ID checks.

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 85af715d2a20e1b522d2aebbd933f067e6b4a7cf..86a8396f6ec286dae1d847060c4b2a51222e9aa3 100644 (file)
@@ -296,7 +296,7 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
 __must_check int media_entity_graph_walk_init(
        struct media_entity_graph *graph, struct media_device *mdev)
 {
-       return 0;
+       return media_entity_enum_init(&graph->ent_enum, mdev);
 }
 EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
 
@@ -306,20 +306,18 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
  */
 void media_entity_graph_walk_cleanup(struct media_entity_graph *graph)
 {
+       media_entity_enum_cleanup(&graph->ent_enum);
 }
 EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
 
 void media_entity_graph_walk_start(struct media_entity_graph *graph,
                                   struct media_entity *entity)
 {
+       media_entity_enum_zero(&graph->ent_enum);
+       media_entity_enum_set(&graph->ent_enum, entity);
+
        graph->top = 0;
        graph->stack[graph->top].entity = NULL;
-       bitmap_zero(graph->entities, MEDIA_ENTITY_ENUM_MAX_ID);
-
-       if (WARN_ON(media_entity_id(entity) >= MEDIA_ENTITY_ENUM_MAX_ID))
-               return;
-
-       __set_bit(media_entity_id(entity), graph->entities);
        stack_push(graph, entity);
 }
 EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
@@ -350,11 +348,9 @@ media_entity_graph_walk_next(struct media_entity_graph *graph)
 
                /* Get the entity in the other end of the link . */
                next = media_entity_other(entity, link);
-               if (WARN_ON(media_entity_id(next) >= MEDIA_ENTITY_ENUM_MAX_ID))
-                       return NULL;
 
                /* Has the entity already been visited? */
-               if (__test_and_set_bit(media_entity_id(next), graph->entities)) {
+               if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
                        link_top(graph) = link_top(graph)->next;
                        continue;
                }
index 7f028ea84911846e06c4d6c51d066f8a261c35da..a53acb099c16f50aff444a47665cd238e30bb8dd 100644 (file)
@@ -103,7 +103,7 @@ struct media_entity_enum {
  * @stack:             Graph traversal stack; the stack contains information
  *                     on the path the media entities to be walked and the
  *                     links through which they were reached.
- * @entities:          Visited entities
+ * @ent_enum:          Visited entities
  * @top:               The top of the stack
  */
 struct media_entity_graph {
@@ -112,7 +112,7 @@ struct media_entity_graph {
                struct list_head *link;
        } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
 
-       DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
+       struct media_entity_enum ent_enum;
        int top;
 };