Hi Laurent, Thanks for your work.
On 2026-05-12 02:56:33 +0300, Laurent Pinchart wrote: > Introduce a vsp1_for_each_format() macro to iterate over format arrays, > to improve readability. No functional change intended. > > Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> > --- > .../media/platform/renesas/vsp1/vsp1_pipe.c | 36 ++++++------------- > 1 file changed, 10 insertions(+), 26 deletions(-) > > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_pipe.c > b/drivers/media/platform/renesas/vsp1/vsp1_pipe.c > index f9c7c75a7ad0..7197f2917417 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_pipe.c > +++ b/drivers/media/platform/renesas/vsp1/vsp1_pipe.c > @@ -229,6 +229,10 @@ static const struct vsp1_format_info > vsp1_video_hsit_formats[] = { > 1, { 32, 0, 0 }, false, false, 1, 1, false }, > }; > > +#define vsp1_for_each_format(info, formats) \ > + for (const struct vsp1_format_info *info = &formats[0]; \ > + info < formats + ARRAY_SIZE(formats); ++info) > + > /** > * vsp1_get_format_info - Retrieve format information for a 4CC > * @vsp1: the VSP1 device > @@ -240,30 +244,20 @@ static const struct vsp1_format_info > vsp1_video_hsit_formats[] = { > const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1, > u32 fourcc) > { > - unsigned int i; > - > - for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) { > - const struct vsp1_format_info *info = &vsp1_video_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_formats) { > if (info->fourcc == fourcc) > return info; > } > > if (vsp1->info->gen == 2) { > - for (i = 0; i < ARRAY_SIZE(vsp1_video_gen2_formats); ++i) { > - const struct vsp1_format_info *info = > - &vsp1_video_gen2_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_gen2_formats) { > if (info->fourcc == fourcc) > return info; > } > } > > if (vsp1_feature(vsp1, VSP1_HAS_HSIT)) { > - for (i = 0; i < ARRAY_SIZE(vsp1_video_hsit_formats); ++i) { > - const struct vsp1_format_info *info = > - &vsp1_video_hsit_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_hsit_formats) { > if (info->fourcc == fourcc) > return info; > } > @@ -287,8 +281,6 @@ const struct vsp1_format_info * > vsp1_get_format_info_by_index(struct vsp1_device *vsp1, unsigned int index, > u32 code) > { > - unsigned int i; > - > if (!code) { > if (index < ARRAY_SIZE(vsp1_video_formats)) > return &vsp1_video_formats[index]; > @@ -308,9 +300,7 @@ vsp1_get_format_info_by_index(struct vsp1_device *vsp1, > unsigned int index, > return NULL; > } > > - for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) { > - const struct vsp1_format_info *info = &vsp1_video_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_formats) { > if (info->mbus == code) { > if (!index) > return info; > @@ -319,10 +309,7 @@ vsp1_get_format_info_by_index(struct vsp1_device *vsp1, > unsigned int index, > } > > if (vsp1->info->gen == 2) { > - for (i = 0; i < ARRAY_SIZE(vsp1_video_gen2_formats); ++i) { > - const struct vsp1_format_info *info = > - &vsp1_video_gen2_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_gen2_formats) { > if (info->mbus == code) { > if (!index) > return info; > @@ -332,10 +319,7 @@ vsp1_get_format_info_by_index(struct vsp1_device *vsp1, > unsigned int index, > } > > if (vsp1_feature(vsp1, VSP1_HAS_HSIT)) { > - for (i = 0; i < ARRAY_SIZE(vsp1_video_hsit_formats); ++i) { > - const struct vsp1_format_info *info = > - &vsp1_video_hsit_formats[i]; > - > + vsp1_for_each_format(info, vsp1_video_hsit_formats) { > if (info->mbus == code) { > if (!index) > return info; > -- > Regards, > > Laurent Pinchart > > -- Kind Regards, Niklas Söderlund
