powerpc/mm: Drop the unnecessary region check
[linux-2.6-block.git] / drivers / media / media-entity.c
index 3498551e618e543799e42ecfff441a597ede5967..0b1cb3559140a1fee04af77890f8dd1131b0f484 100644 (file)
@@ -662,6 +662,32 @@ static void __media_entity_remove_link(struct media_entity *entity,
        kfree(link);
 }
 
+int media_get_pad_index(struct media_entity *entity, bool is_sink,
+                       enum media_pad_signal_type sig_type)
+{
+       int i;
+       bool pad_is_sink;
+
+       if (!entity)
+               return -EINVAL;
+
+       for (i = 0; i < entity->num_pads; i++) {
+               if (entity->pads[i].flags == MEDIA_PAD_FL_SINK)
+                       pad_is_sink = true;
+               else if (entity->pads[i].flags == MEDIA_PAD_FL_SOURCE)
+                       pad_is_sink = false;
+               else
+                       continue;       /* This is an error! */
+
+               if (pad_is_sink != is_sink)
+                       continue;
+               if (entity->pads[i].sig_type == sig_type)
+                       return i;
+       }
+       return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(media_get_pad_index);
+
 int
 media_create_pad_link(struct media_entity *source, u16 source_pad,
                         struct media_entity *sink, u16 sink_pad, u32 flags)