On 30/07/2022 14:11, Sakari Ailus wrote:
@@ -203,12 +204,12 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
if (mdev)
mutex_lock(&mdev->graph_mutex);
- for (i = 0; i < num_pads; i++) {
- pads[i].entity = entity;
- pads[i].index = i;
+ media_entity_for_each_pad(entity, iter) {
+ iter->entity = entity;
+ iter->index = i++;
if (mdev)
media_gobj_create(mdev, MEDIA_GRAPH_PAD,
- &entity->pads[i].graph_obj);
+ &iter->graph_obj);
I know it was wrongly aligned but fixing it would be nice here.
Ok.
}
if (mdev)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index a9a1c0ec5d1c..6b6fea6a713e 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -315,6 +315,18 @@ struct media_entity {
} info;
};
+/**
+ * media_entity_for_each_pad - Iterate on all pads in an entity
+ * @entity: The entity the pads belong to
+ * @iter: The iterator pad
+ *
+ * Iterate on all pads in a media entity.
+ */
+#define media_entity_for_each_pad(entity, iter) \
+ for (iter = (entity)->pads; \
+ iter < &(entity)->pads[(entity)->num_pads]; \
+ ++iter)
It'd be nice to align the backslashes.
They are aligned. But aligning with tabs can get messed up visually in
patches as there's a +/- at the front of the line.
Tomi