]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: vimc: Don't iterate over single pad
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 24 Apr 2024 23:57:33 +0000 (02:57 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 26 Jun 2024 14:39:34 +0000 (16:39 +0200)
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.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/test-drivers/vimc/vimc-debayer.c
drivers/media/test-drivers/vimc/vimc-sensor.c

index d72ed086e00bb40247149902835b0bc7cef97ed8..e1bf6db730503f4dedbf1b6b636a7cc35df8677c 100644 (file)
@@ -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;
 }
index 5e34b1aed95e8621c63a9b5b80581f6725ca05aa..b535b3ffecff9914df47fd71151ba2b2a7ad309e 100644 (file)
@@ -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;
-
-       for (i = 0; i < sd->entity.num_pads; i++) {
-               struct v4l2_mbus_framefmt *mf;
+       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;
 }