media: atomisp: do not use err var when checking port validity for ISP2400
authorTsuchiya Yuto <kitakar@gmail.com>
Sun, 17 Oct 2021 16:19:44 +0000 (01:19 +0900)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 15 Nov 2021 08:11:36 +0000 (08:11 +0000)
Currently, the `port >= N_CSI_PORTS || err` checks for ISP2400 are always
evaluated as true because the err variable is set to `-EINVAL` on
declaration but the variable is never used until the evaluation.

Looking at the diff of commit 3c0538fbad9f ("media: atomisp: get rid of
most checks for ISP2401 version"), the `port >= N_CSI_PORTS` check is
for ISP2400 and the err variable check is for ISP2401. Fix this issue
by adding ISP version test there accordingly.

Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version")
Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/sh_css_mipi.c

index 483d40a467c749762887591c87f671a82473620c..65fc93c5d56bc2bf4fd83403fda7536b4b5d7341 100644 (file)
@@ -430,7 +430,8 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
 
        assert(port < N_CSI_PORTS);
 
-       if (port >= N_CSI_PORTS || err) {
+       if ((!IS_ISP2401 && port >= N_CSI_PORTS) ||
+           (IS_ISP2401 && err)) {
                ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
                                    "allocate_mipi_frames(%p) exit: error: port is not correct (port=%d).\n",
                                    pipe, port);
@@ -559,7 +560,8 @@ free_mipi_frames(struct ia_css_pipe *pipe)
 
                assert(port < N_CSI_PORTS);
 
-               if (port >= N_CSI_PORTS || err) {
+               if ((!IS_ISP2401 && port >= N_CSI_PORTS) ||
+                   (IS_ISP2401 && err)) {
                        ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
                                            "free_mipi_frames(%p, %d) exit: error: pipe port is not correct.\n",
                                            pipe, port);
@@ -670,7 +672,8 @@ send_mipi_frames(struct ia_css_pipe *pipe)
 
        assert(port < N_CSI_PORTS);
 
-       if (port >= N_CSI_PORTS || err) {
+       if ((!IS_ISP2401 && port >= N_CSI_PORTS) ||
+           (IS_ISP2401 && err)) {
                IA_CSS_ERROR("send_mipi_frames(%p) exit: invalid port specified (port=%d).\n",
                             pipe, port);
                return err;