From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Biju Das <biju.das.jz@bp.renesas.com>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: Re: [PATCH 09/11] media: renesas: vsp1: Simplify iteration over format arrays
Date: Wed, 13 May 2026 21:44:05 +0200 [thread overview]
Message-ID: <20260513194405.GL332351@ragnatech.se> (raw)
In-Reply-To: <20260511235637.3468558-10-laurent.pinchart+renesas@ideasonboard.com>
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 <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> .../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
next prev parent reply other threads:[~2026-05-13 19:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 23:56 [PATCH 00/11] media: renesas: vsp1: Modernize the driver Laurent Pinchart
2026-05-11 23:56 ` [PATCH 01/11] media: renesas: vsp1: Avoid forward function declaration Laurent Pinchart
2026-05-13 19:09 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 02/11] media: renesas: vsp1: Split vsp1_du_setup_lif() Laurent Pinchart
2026-05-13 19:11 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 03/11] drm: renesas: rcar-du: Switch to new VSP API Laurent Pinchart
2026-05-13 19:12 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 04/11] drm: renesas: rz-du: " Laurent Pinchart
2026-05-13 19:13 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 05/11] media: renesas: vsp1: Use mutex guards Laurent Pinchart
2026-05-13 19:20 ` Niklas Söderlund
2026-05-13 19:40 ` Laurent Pinchart
2026-05-11 23:56 ` [PATCH 06/11] media: renesas: vsp1: Use mutex scoped guards Laurent Pinchart
2026-05-13 19:24 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 07/11] media: renesas: vsp1: Use spinlock guards Laurent Pinchart
2026-05-13 19:29 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 08/11] media: renesas: vsp1: Use spinlock scoped guards Laurent Pinchart
2026-05-13 19:37 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 09/11] media: renesas: vsp1: Simplify iteration over format arrays Laurent Pinchart
2026-05-13 19:44 ` Niklas Söderlund [this message]
2026-05-11 23:56 ` [PATCH 10/11] media: renesas: vsp1: Declare index variables in for loop statement Laurent Pinchart
2026-05-13 20:29 ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 11/11] media: renesas: vsp1: Drop deprecated vsp1_du_setup_lif() function Laurent Pinchart
2026-05-13 20:31 ` Niklas Söderlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260513194405.GL332351@ragnatech.se \
--to=niklas.soderlund@ragnatech.se \
--cc=airlied@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox