media: staging: media: starfive: Clean pad selection in isp_try_format()
authorChanghuang Liang <changhuang.liang@starfivetech.com>
Tue, 12 Mar 2024 02:45:20 +0000 (02:45 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 3 May 2024 09:33:16 +0000 (10:33 +0100)
The code to select isp_dev->formats[] is overly complicated.  We can
just use the "pad" as the index.  This will making adding new pads
easier in future patches.  No functional change.

Link: https://lore.kernel.org/linux-media/20240312024520.11022-1-changhuang.liang@starfivetech.com
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/starfive/camss/stf-isp.c

index d50616ef351ed30b24aacf43e3f47b890f625ae0..4e6e267368527e232e2508dd5fc2ac2cf913986d 100644 (file)
@@ -10,9 +10,6 @@
 
 #include "stf-camss.h"
 
-#define SINK_FORMATS_INDEX     0
-#define SOURCE_FORMATS_INDEX   1
-
 static int isp_set_selection(struct v4l2_subdev *sd,
                             struct v4l2_subdev_state *state,
                             struct v4l2_subdev_selection *sel);
@@ -94,10 +91,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
                return;
        }
 
-       if (pad == STF_ISP_PAD_SINK)
-               formats = &isp_dev->formats[SINK_FORMATS_INDEX];
-       else if (pad == STF_ISP_PAD_SRC)
-               formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
+       formats = &isp_dev->formats[pad];
 
        fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
                             STFCAMSS_FRAME_MAX_WIDTH);
@@ -123,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
                if (code->index >= ARRAY_SIZE(isp_formats_sink))
                        return -EINVAL;
 
-               formats = &isp_dev->formats[SINK_FORMATS_INDEX];
+               formats = &isp_dev->formats[code->pad];
                code->code = formats->fmts[code->index].code;
        } else {
                struct v4l2_mbus_framefmt *sink_fmt;