[05/17] media: atomisp: pci: fix inverted error check for ia_css_mipi_is_source_port_valid()
Message ID | 20211017161958.44351-6-kitakar@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1mc8uQ-006Wa5-EJ; Sun, 17 Oct 2021 16:21:14 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344135AbhJQQXW (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Sun, 17 Oct 2021 12:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344103AbhJQQXQ (ORCPT <rfc822;linux-media@vger.kernel.org>); Sun, 17 Oct 2021 12:23:16 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF26AC06176C; Sun, 17 Oct 2021 09:21:06 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 133so13550028pgb.1; Sun, 17 Oct 2021 09:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kPQMaAl18vlXvtzY3u2mFwVBriklZfpAQgwXY9rKh7o=; b=nMgftG/DJnSH7FCQYuApWdUYV+mxq1ZnJSRJjmHhsiR1b/igSdXAML30k1n/UfRUx7 P/Cxy1p3Kl5tx2kDt6hrTthg0WnjWP6YykTL9HvhPkp2adma+BPr9W1zS5Y1sfXaGKLy jBdOdtDMKDC8x7fWcqQ+t9prMgAyQwOtpnEblfAPyVENuPdZObTboG2xnRG6BX5Ldb6J wvxbEmthg3ey5k+sX4MJQ+y/DTpd9IsYZZihsvf8wO97Y13FcsgnVc8i9iaAu8HzB/8g 5U+C7Gf4UGvQPSOcyeYLpx40dGvyBZdPXGyq2/1ldP+EUlOBWUwj7a6nMTfdxhpeSnl3 iQyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kPQMaAl18vlXvtzY3u2mFwVBriklZfpAQgwXY9rKh7o=; b=gx+W+oL0Ki3uTWzYAEVa4rE5k1ToSq3R+NKPz1c3GeiFPA0ZZSW1u1SvQaf1wjodDH gluEPo5rt9nrs8LDQboXRmwffDgMpNApsBF6rIAbxVphUWNSLEVomADrPxHXEsEu+qbO cgxOGpqcJ0GVSXwRHnMGgEL6Xk0+i78YkZl1mNwGgYPI2Ew75MFqAiD0C6eMeR7MwRSe WsSTgOr6obKGLjCzE3e1wGteA7A77zzgPKSc6nj9/TpKDDgUk/lDXyOXH1xXQhxz4N/V mVeYfyaPjeyE9M32OzWLBXq8x21VtHtGoLYzuXq/Sa+amORG1X22JUoupTeaKLUtzhhF h1TQ== X-Gm-Message-State: AOAM530vFTGWGrsRfQC7noNMlX0qMjQrOxvoPhWkEqBWLYW5NslInoOn Wuqe1s1zdQGYaDjxZriTn/A= X-Google-Smtp-Source: ABdhPJwylO8lupxyYn8xSrX8xDfdHl+dQQeZXlCuVVmcKZ/ex48H0ClPY3krGCeMRZNLTxdK7A5Sng== X-Received: by 2002:a62:1c4e:0:b0:44d:76b:de98 with SMTP id c75-20020a621c4e000000b0044d076bde98mr24413785pfc.16.1634487666153; Sun, 17 Oct 2021 09:21:06 -0700 (PDT) Received: from sbwpb-arch.flets-east.jp ([2400:4052:6980:3800:dba7:2b1f:3f26:a5ec]) by smtp.gmail.com with ESMTPSA id mu11sm5155444pjb.20.2021.10.17.09.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Oct 2021 09:21:05 -0700 (PDT) From: Tsuchiya Yuto <kitakar@gmail.com> Cc: Hans de Goede <hdegoede@redhat.com>, Patrik Gfeller <patrik.gfeller@gmail.com>, Tsuchiya Yuto <kitakar@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Sakari Ailus <sakari.ailus@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Aline Santana Cordeiro <alinesantanacordeiro@gmail.com>, Yang Yingliang <yangyingliang@huawei.com>, Alan <alan@linux.intel.com>, Dinghao Liu <dinghao.liu@zju.edu.cn>, Deepak R Varma <drv@mailo.com>, Alex Dewar <alex.dewar90@gmail.com>, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 05/17] media: atomisp: pci: fix inverted error check for ia_css_mipi_is_source_port_valid() Date: Mon, 18 Oct 2021 01:19:45 +0900 Message-Id: <20211017161958.44351-6-kitakar@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211017161958.44351-1-kitakar@gmail.com> References: <20211017161958.44351-1-kitakar@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.6 (----) X-LSpam-Report: No, score=-4.6 required=5.0 tests=BAYES_00=-1.9,DKIM_ADSP_CUSTOM_MED=0.001,DKIM_SIGNED=0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,T_DKIM_INVALID=0.01 autolearn=ham autolearn_force=no |
Series |
various fixes for atomisp to make it work
|
|
Commit Message
Tsuchiya Yuto
Oct. 17, 2021, 4:19 p.m. UTC
The function ia_css_mipi_is_source_port_valid() returns true if the port
is valid. So, we can't use the existing err variable as is.
To fix this issue while reusing that variable, invert the return value
when assigning it to the variable.
Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version")
Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
---
.../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++-------
1 file changed, 15 insertions(+), 9 deletions(-)
Comments
On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > The function ia_css_mipi_is_source_port_valid() returns true if the port > is valid. So, we can't use the existing err variable as is. > > To fix this issue while reusing that variable, invert the return value > when assigning it to the variable. > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > --- > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > index 65fc93c5d56b..c1f2f6151c5f 100644 > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > return 0; /* AM TODO: Check */ > } > > - if (!IS_ISP2401) > + if (!IS_ISP2401) { > port = (unsigned int)pipe->stream->config.source.port.port; > - else > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > + } else { > + /* Returns true if port is valid. So, invert it */ > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); Don't invert it... This isn't supposed to return 1 on failure it's supposed to return negative error codes. > + } > > assert(port < N_CSI_PORTS); > > @@ -553,10 +555,12 @@ free_mipi_frames(struct ia_css_pipe *pipe) > return err; > } > > - if (!IS_ISP2401) > + if (!IS_ISP2401) { > port = (unsigned int)pipe->stream->config.source.port.port; > - else > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > + } else { > + /* Returns true if port is valid. So, invert it */ > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); Presumably the same here? > + } > > assert(port < N_CSI_PORTS); > > @@ -665,10 +669,12 @@ send_mipi_frames(struct ia_css_pipe *pipe) > /* TODO: AM: maybe this should be returning an error. */ > } > > - if (!IS_ISP2401) > + if (!IS_ISP2401) { > port = (unsigned int)pipe->stream->config.source.port.port; > - else > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > + } else { > + /* Returns true if port is valid. So, invert it */ > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); Same? > + } > > assert(port < N_CSI_PORTS); regards, dan carpenter
On Tue, 2021-11-02 at 14:33 +0300, Dan Carpenter wrote: > On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > > The function ia_css_mipi_is_source_port_valid() returns true if the port > > is valid. So, we can't use the existing err variable as is. > > > > To fix this issue while reusing that variable, invert the return value > > when assigning it to the variable. > > > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > > --- > > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > index 65fc93c5d56b..c1f2f6151c5f 100644 > > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > > return 0; /* AM TODO: Check */ > > } > > > > - if (!IS_ISP2401) > > + if (!IS_ISP2401) { > > port = (unsigned int)pipe->stream->config.source.port.port; > > - else > > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > > + } else { > > + /* Returns true if port is valid. So, invert it */ > > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); > > Don't invert it... This isn't supposed to return 1 on failure it's > supposed to return negative error codes. You mean I should instead modify the return value of ia_css_mipi_is_source_port_valid() ? Yeah, I also thought that the current true/false return value was a little bit confusing. In another words, should the function return: - negative values (maybe -EINVAL for this case) for invalid case - 0 for valid case instead? and if we go this way, we should also rename the function name like - check_ia_css_mipi_source_port_validity or something. How does this sound? Regards, Tsuchiya Yuto
On Tue, Nov 09, 2021 at 12:00:29AM +0900, Tsuchiya Yuto wrote: > On Tue, 2021-11-02 at 14:33 +0300, Dan Carpenter wrote: > > On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > > > The function ia_css_mipi_is_source_port_valid() returns true if the port > > > is valid. So, we can't use the existing err variable as is. > > > > > > To fix this issue while reusing that variable, invert the return value > > > when assigning it to the variable. > > > > > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > > > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > > > --- > > > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > index 65fc93c5d56b..c1f2f6151c5f 100644 > > > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > > > return 0; /* AM TODO: Check */ > > > } > > > > > > - if (!IS_ISP2401) > > > + if (!IS_ISP2401) { > > > port = (unsigned int)pipe->stream->config.source.port.port; > > > - else > > > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > > > + } else { > > > + /* Returns true if port is valid. So, invert it */ > > > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); > > > > Don't invert it... This isn't supposed to return 1 on failure it's > > supposed to return negative error codes. > > You mean I should instead modify the return value of > ia_css_mipi_is_source_port_valid() ? > No. ia_css_mipi_is_source_port_valid() is fine. It has a boolean name so returning bool is fine. What I'm saying is that allocate_mipi_frames() should do: if (!ia_css_mipi_is_source_port_valid(pipe, &port)) err = -EINVAL; Otherwise it returns negative error codes and 1 on failure. regards, dan carpenter
<removed Alan from Cc as the mail address not reachable> On Mon, 2021-11-08 at 18:14 +0300, Dan Carpenter wrote: > On Tue, Nov 09, 2021 at 12:00:29AM +0900, Tsuchiya Yuto wrote: > > On Tue, 2021-11-02 at 14:33 +0300, Dan Carpenter wrote: > > > On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > > > > The function ia_css_mipi_is_source_port_valid() returns true if the port > > > > is valid. So, we can't use the existing err variable as is. > > > > > > > > To fix this issue while reusing that variable, invert the return value > > > > when assigning it to the variable. > > > > > > > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > > > > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > > > > --- > > > > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > > > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > > > > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > index 65fc93c5d56b..c1f2f6151c5f 100644 > > > > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > > > > return 0; /* AM TODO: Check */ > > > > } > > > > > > > > - if (!IS_ISP2401) > > > > + if (!IS_ISP2401) { > > > > port = (unsigned int)pipe->stream->config.source.port.port; > > > > - else > > > > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > > > > + } else { > > > > + /* Returns true if port is valid. So, invert it */ > > > > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); > > > > > > Don't invert it... This isn't supposed to return 1 on failure it's > > > supposed to return negative error codes. > > > > You mean I should instead modify the return value of > > ia_css_mipi_is_source_port_valid() ? > > > > No. ia_css_mipi_is_source_port_valid() is fine. It has a boolean name > so returning bool is fine. What I'm saying is that allocate_mipi_frames() > should do: > > if (!ia_css_mipi_is_source_port_valid(pipe, &port)) > err = -EINVAL; > > Otherwise it returns negative error codes and 1 on failure. Ah, I see! Thank you. I feel I'm a stupid... I'll do so in v2. Regards, Tsuchiya Yuto
On Tue, Nov 09, 2021 at 12:25:52AM +0900, Tsuchiya Yuto wrote: > > Ah, I see! Thank you. I feel I'm a stupid... I'll do so in v2. > Not at all. It's easy for me to not introduce bugs because I never write new code. I just sit here all day obsessing about error handling. regards, dan carpenter
Em Tue, 09 Nov 2021 00:25:52 +0900 Tsuchiya Yuto <kitakar@gmail.com> escreveu: > <removed Alan from Cc as the mail address not reachable> > > On Mon, 2021-11-08 at 18:14 +0300, Dan Carpenter wrote: > > On Tue, Nov 09, 2021 at 12:00:29AM +0900, Tsuchiya Yuto wrote: > > > On Tue, 2021-11-02 at 14:33 +0300, Dan Carpenter wrote: > > > > On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > > > > > The function ia_css_mipi_is_source_port_valid() returns true if the port > > > > > is valid. So, we can't use the existing err variable as is. > > > > > > > > > > To fix this issue while reusing that variable, invert the return value > > > > > when assigning it to the variable. > > > > > > > > > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > > > > > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > > > > > --- > > > > > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > > > > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > > > > > > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > index 65fc93c5d56b..c1f2f6151c5f 100644 > > > > > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > > > > > return 0; /* AM TODO: Check */ > > > > > } > > > > > > > > > > - if (!IS_ISP2401) > > > > > + if (!IS_ISP2401) { > > > > > port = (unsigned int)pipe->stream->config.source.port.port; > > > > > - else > > > > > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > > > > > + } else { > > > > > + /* Returns true if port is valid. So, invert it */ > > > > > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); > > > > > > > > Don't invert it... This isn't supposed to return 1 on failure it's > > > > supposed to return negative error codes. > > > > > > You mean I should instead modify the return value of > > > ia_css_mipi_is_source_port_valid() ? > > > > > > > No. ia_css_mipi_is_source_port_valid() is fine. It has a boolean name > > so returning bool is fine. What I'm saying is that allocate_mipi_frames() > > should do: > > > > if (!ia_css_mipi_is_source_port_valid(pipe, &port)) > > err = -EINVAL; > > > > Otherwise it returns negative error codes and 1 on failure. > > Ah, I see! Thank you. I feel I'm a stupid... I'll do so in v2. I would prefer if you could send such changes on new patches. Regards, Mauro
On Mon, 2021-11-08 at 16:35 +0000, Mauro Carvalho Chehab wrote: > Em Tue, 09 Nov 2021 00:25:52 +0900 > Tsuchiya Yuto <kitakar@gmail.com> escreveu: > > > <removed Alan from Cc as the mail address not reachable> > > > > On Mon, 2021-11-08 at 18:14 +0300, Dan Carpenter wrote: > > > On Tue, Nov 09, 2021 at 12:00:29AM +0900, Tsuchiya Yuto wrote: > > > > On Tue, 2021-11-02 at 14:33 +0300, Dan Carpenter wrote: > > > > > On Mon, Oct 18, 2021 at 01:19:45AM +0900, Tsuchiya Yuto wrote: > > > > > > The function ia_css_mipi_is_source_port_valid() returns true if the port > > > > > > is valid. So, we can't use the existing err variable as is. > > > > > > > > > > > > To fix this issue while reusing that variable, invert the return value > > > > > > when assigning it to the variable. > > > > > > > > > > > > Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version") > > > > > > Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com> > > > > > > --- > > > > > > .../staging/media/atomisp/pci/sh_css_mipi.c | 24 ++++++++++++------- > > > > > > 1 file changed, 15 insertions(+), 9 deletions(-) > > > > > > > > > > > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > > index 65fc93c5d56b..c1f2f6151c5f 100644 > > > > > > --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > > +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c > > > > > > @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, > > > > > > return 0; /* AM TODO: Check */ > > > > > > } > > > > > > > > > > > > - if (!IS_ISP2401) > > > > > > + if (!IS_ISP2401) { > > > > > > port = (unsigned int)pipe->stream->config.source.port.port; > > > > > > - else > > > > > > - err = ia_css_mipi_is_source_port_valid(pipe, &port); > > > > > > + } else { > > > > > > + /* Returns true if port is valid. So, invert it */ > > > > > > + err = !ia_css_mipi_is_source_port_valid(pipe, &port); > > > > > > > > > > Don't invert it... This isn't supposed to return 1 on failure it's > > > > > supposed to return negative error codes. > > > > > > > > You mean I should instead modify the return value of > > > > ia_css_mipi_is_source_port_valid() ? > > > > > > > > > > No. ia_css_mipi_is_source_port_valid() is fine. It has a boolean name > > > so returning bool is fine. What I'm saying is that allocate_mipi_frames() > > > should do: > > > > > > if (!ia_css_mipi_is_source_port_valid(pipe, &port)) > > > err = -EINVAL; > > > > > > Otherwise it returns negative error codes and 1 on failure. > > > > Ah, I see! Thank you. I feel I'm a stupid... I'll do so in v2. > > I would prefer if you could send such changes on new patches. I'm a little bit too late, sorry. For the record, the return value issue pointed out here is already gone with patch ("media: atomisp: sh_css_mipi: cleanup the code") [1]. Thanks! [1] https://lore.kernel.org/linux-media/b541d4c9923154be7ae0518d01ce994acbef3f9b.1637142905.git.mchehab+huawei@kernel.org/
diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c index 65fc93c5d56b..c1f2f6151c5f 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c @@ -423,10 +423,12 @@ allocate_mipi_frames(struct ia_css_pipe *pipe, return 0; /* AM TODO: Check */ } - if (!IS_ISP2401) + if (!IS_ISP2401) { port = (unsigned int)pipe->stream->config.source.port.port; - else - err = ia_css_mipi_is_source_port_valid(pipe, &port); + } else { + /* Returns true if port is valid. So, invert it */ + err = !ia_css_mipi_is_source_port_valid(pipe, &port); + } assert(port < N_CSI_PORTS); @@ -553,10 +555,12 @@ free_mipi_frames(struct ia_css_pipe *pipe) return err; } - if (!IS_ISP2401) + if (!IS_ISP2401) { port = (unsigned int)pipe->stream->config.source.port.port; - else - err = ia_css_mipi_is_source_port_valid(pipe, &port); + } else { + /* Returns true if port is valid. So, invert it */ + err = !ia_css_mipi_is_source_port_valid(pipe, &port); + } assert(port < N_CSI_PORTS); @@ -665,10 +669,12 @@ send_mipi_frames(struct ia_css_pipe *pipe) /* TODO: AM: maybe this should be returning an error. */ } - if (!IS_ISP2401) + if (!IS_ISP2401) { port = (unsigned int)pipe->stream->config.source.port.port; - else - err = ia_css_mipi_is_source_port_valid(pipe, &port); + } else { + /* Returns true if port is valid. So, invert it */ + err = !ia_css_mipi_is_source_port_valid(pipe, &port); + } assert(port < N_CSI_PORTS);