From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F5AF2C99 for ; Mon, 8 Nov 2021 15:25:57 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id j9so15467187pgh.1 for ; Mon, 08 Nov 2021 07:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=vPyJr+4qmWXSKsoVulut/GUWobZxrCQk03WwnLZG85Q=; b=TCem6/Qje9Aic+a5CzQoHwLA5+wgX8Yl6Rv8spN0zZXx6nxquLe8/6JlghITAaUV85 lULdtQhrq/9PGxZm8Mn+ocVv6PWConrf+Tsrr6NmKX+G715Ak1/ElkaAyNYgRs8/g61m 2VbOnFjydzm8AqngcKjWCsEc4zipRNoQ9rNzlckVnabZXmFe8aQWJOxs9bqkacNft/cb Js4JEIpejkxXUfCiQsHpa2AXFrv4ek1e1vLhfMW2H6INrURc+g2+W6xW7e30YgXg7gzy 4nkXNyWWmXOoubygMz5/8XkqklSkK5W1sEauiGiE6QzcSwz/Z4LP44PD1oH6zSp1ets0 lPVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=vPyJr+4qmWXSKsoVulut/GUWobZxrCQk03WwnLZG85Q=; b=W0zNeWLSD8JZ+6wok9qyAlBNsIHqozGzwAf3O3prQWrRTx++3by0m+KEk22lh2emtF +ABQmz9n4vJ+tUZxHp9LcMsclhCkHbDlC8OLEbi+P8ndecKwMwxAkwX3Jd9fh2k+qAgH o/+nc8HlVtQV9O1PKOkwHeqtbXEJq5arlSIQo5IAEVWyv9IcWmV5Ir83qy0+rrz3hXHz /ord2BppQWO1HnGGgRbxb9GlMDBVysJgw4ixfBz2TtHEBI0egyRltMtbkcohtUFbrUdI eLW4Qj2KaSjk4AGNdGOSjLlLFHxkI5i6RV/i6/n1nuzw85OGUqzv2LW1aNVPwEml/PH1 D17w== X-Gm-Message-State: AOAM530dyeDDREgYPajsAVZUSEvjWt35h44CBe6xqq33j8G92F1UdmQn tzNDaQ1MbFd5b2j3Q7y7PSI= X-Google-Smtp-Source: ABdhPJzWSFewdvnFvrYlEolrd4fh2DtHFo6fRGA+sJCKTWOJ51qsmIfpwb5heta9Xboq/m704F/euA== X-Received: by 2002:aa7:9e9c:0:b0:49f:c7cf:ff5 with SMTP id p28-20020aa79e9c000000b0049fc7cf0ff5mr277917pfq.62.1636385157071; Mon, 08 Nov 2021 07:25:57 -0800 (PST) Received: from ?IPv6:2400:4052:6980:3800:dba7:2b1f:3f26:a5ec? ([2400:4052:6980:3800:dba7:2b1f:3f26:a5ec]) by smtp.gmail.com with ESMTPSA id j6sm12763106pgq.0.2021.11.08.07.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 07:25:56 -0800 (PST) Message-ID: Subject: Re: [PATCH 05/17] media: atomisp: pci: fix inverted error check for ia_css_mipi_is_source_port_valid() From: Tsuchiya Yuto To: Dan Carpenter Cc: Hans de Goede , Patrik Gfeller , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Hans Verkuil , Aline Santana Cordeiro , Yang Yingliang , Dinghao Liu , Deepak R Varma , Alex Dewar , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Date: Tue, 09 Nov 2021 00:25:52 +0900 In-Reply-To: <20211108151455.GI2001@kadam> References: <20211017161958.44351-1-kitakar@gmail.com> <20211017161958.44351-6-kitakar@gmail.com> <20211102113332.GC2794@kadam> <20211108151455.GI2001@kadam> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 > > > > --- > > > > .../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