From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-media@vger.kernel.org,
Kieran Bingham <kieran.bingham@ideasonboard.com>
Subject: Re: [PATCH v1 1/9] media: vimc: Don't iterate over single pad
Date: Thu, 30 May 2024 22:45:15 +0300 [thread overview]
Message-ID: <20240530194515.GA28160@pendragon.ideasonboard.com> (raw)
In-Reply-To: <bad644d0-f139-4df4-bac8-e64cc8e8324c@linuxfoundation.org>
Hi Shuah,
On Thu, May 30, 2024 at 01:27:53PM -0600, Shuah Khan wrote:
> On 4/24/24 17:57, Laurent Pinchart wrote:
> > The .init_state() operations of the debayer and sensor entities iterate
> > over the entity's pads. In practice, the iteration covers a single pad
> > only. Access the pad directly and remove the loops.
>
> I am not seeing much of a reason to do this. This code is good
> even when num_pads change.
>
> Don't change the loops.
Why so ? Beside the fact that the loop wastes some CPU cycles, the
current code implies that there would be multiple source pads, which is
confusing for the reader. I think the result of this patch is both
improved efficiency and improved readability.
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > drivers/media/test-drivers/vimc/vimc-debayer.c | 9 +++------
> > drivers/media/test-drivers/vimc/vimc-sensor.c | 10 +++-------
> > 2 files changed, 6 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/media/test-drivers/vimc/vimc-debayer.c b/drivers/media/test-drivers/vimc/vimc-debayer.c
> > index d72ed086e00b..e1bf6db73050 100644
> > --- a/drivers/media/test-drivers/vimc/vimc-debayer.c
> > +++ b/drivers/media/test-drivers/vimc/vimc-debayer.c
> > @@ -155,16 +155,13 @@ static int vimc_debayer_init_state(struct v4l2_subdev *sd,
> > {
> > struct vimc_debayer_device *vdebayer = v4l2_get_subdevdata(sd);
> > struct v4l2_mbus_framefmt *mf;
> > - unsigned int i;
> >
> > mf = v4l2_subdev_state_get_format(sd_state, 0);
> > *mf = sink_fmt_default;
> >
> > - for (i = 1; i < sd->entity.num_pads; i++) {
> > - mf = v4l2_subdev_state_get_format(sd_state, i);
> > - *mf = sink_fmt_default;
> > - mf->code = vdebayer->src_code;
> > - }
> > + mf = v4l2_subdev_state_get_format(sd_state, 1);
> > + *mf = sink_fmt_default;
> > + mf->code = vdebayer->src_code;
> >
> > return 0;
> > }
> > diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/test-drivers/vimc/vimc-sensor.c
> > index 5e34b1aed95e..b535b3ffecff 100644
> > --- a/drivers/media/test-drivers/vimc/vimc-sensor.c
> > +++ b/drivers/media/test-drivers/vimc/vimc-sensor.c
> > @@ -44,14 +44,10 @@ static const struct v4l2_mbus_framefmt fmt_default = {
> > static int vimc_sensor_init_state(struct v4l2_subdev *sd,
> > struct v4l2_subdev_state *sd_state)
> > {
> > - unsigned int i;
> > + struct v4l2_mbus_framefmt *mf;
> >
> > - for (i = 0; i < sd->entity.num_pads; i++) {
> > - struct v4l2_mbus_framefmt *mf;
> > -
> > - mf = v4l2_subdev_state_get_format(sd_state, i);
> > - *mf = fmt_default;
> > - }
> > + mf = v4l2_subdev_state_get_format(sd_state, 0);
> > + *mf = fmt_default;
> >
> > return 0;
> > }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2024-05-30 19:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 23:57 [PATCH v1 0/9] media: vimc improvements Laurent Pinchart
2024-04-24 23:57 ` [PATCH v1 1/9] media: vimc: Don't iterate over single pad Laurent Pinchart
2024-05-30 19:27 ` Shuah Khan
2024-05-30 19:45 ` Laurent Pinchart [this message]
2024-05-30 20:18 ` Shuah Khan
2024-05-30 20:21 ` Laurent Pinchart
2024-05-30 20:58 ` Shuah Khan
2024-06-20 10:47 ` Hans Verkuil
2024-06-20 13:00 ` Sakari Ailus
2024-06-20 15:33 ` Shuah Khan
2024-06-20 13:01 ` Sakari Ailus
2024-04-24 23:57 ` [PATCH v1 2/9] media: vimc: Constify vimc_ent_type structures Laurent Pinchart
2024-05-30 19:28 ` Shuah Khan
2024-04-24 23:57 ` [PATCH v1 3/9] media: vimc: Constify the ent_config array Laurent Pinchart
2024-05-30 19:29 ` Shuah Khan
2024-04-24 23:57 ` [PATCH v1 4/9] media: vimc: scaler: Rename vic_sca_pad enum to vimc_scaler_pad Laurent Pinchart
2024-05-30 19:29 ` Shuah Khan
2024-04-24 23:57 ` [PATCH v1 5/9] media: vimc: Centralize subdev internal_ops initialization Laurent Pinchart
2024-05-30 19:31 ` Shuah Khan
2024-04-24 23:57 ` [PATCH v1 6/9] media: vimc: Initialize subdev active state Laurent Pinchart
2024-04-24 23:57 ` [PATCH v1 7/9] media: vimc: sensor: Use " Laurent Pinchart
2024-04-24 23:57 ` [PATCH v1 8/9] media: vimc: debayer: " Laurent Pinchart
2024-04-24 23:57 ` [PATCH v1 9/9] media: vimc: scaler: " Laurent Pinchart
2024-05-05 20:36 ` [PATCH v1 0/9] media: vimc improvements Laurent Pinchart
2024-05-28 15:49 ` Shuah Khan
2024-05-30 19:34 ` Shuah Khan
2024-06-20 15:59 ` Shuah Khan
2024-06-20 16:09 ` Laurent Pinchart
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=20240530194515.GA28160@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.