From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 982D6C4338F for ; Mon, 2 Aug 2021 10:19:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56E7560F5A for ; Mon, 2 Aug 2021 10:19:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 56E7560F5A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8TGHSTPv++1NUb8xMuXdtoq1guljMqngor0iS9xVSnQ=; b=OcSlmZMl2AmyWx OqS4NIqDHSW3vCsl7uCxK7oBaZavu+wljUscPi60/7YEKkFBpiyX5HwLIRGX6GIdoJz3RFbGii+YC pK1jhI3x68+YYL3344iwwvkrS5sisfq7S8WgHJkvOwTGQomiJ+PoyiDoHxOTREMgf/1atOGIziaox ++/qyedf2zDmUVi2Nl6V4lNtxQmFjN4HY6ye61/5S131gWOWtAl0z82SwhtV0pQ5CFJukuOseeeVG lWxe/6CalGp2G1ZghcjE9YY8VACAck6UiScgufJ8ohj6BZDB1FyY79d7rbNQA6C6PodAJ7RL7aQT/ risbFYcNerv+LQ3PQw2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAV0h-00Fhya-7b; Mon, 02 Aug 2021 10:17:27 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAV0d-00FhxP-Fb for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 10:17:25 +0000 Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GdYpF5Ldcz6B9ml; Mon, 2 Aug 2021 18:17:09 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 2 Aug 2021 12:17:16 +0200 Received: from localhost (10.47.9.82) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 2 Aug 2021 11:17:15 +0100 Date: Mon, 2 Aug 2021 11:16:47 +0100 From: Jonathan Cameron To: tangbin CC: Jonathan Cameron , , , , , , , , Subject: Re: [PATCH] iio: adc: fsl-imx25-gcq: fix the right check and simplify code Message-ID: <20210802111647.000012ee@Huawei.com> In-Reply-To: References: <20210727125209.28248-1-tangbin@cmss.chinamobile.com> <20210731174551.188aee79@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.47.9.82] X-ClientProxiedBy: lhreml743-chm.china.huawei.com (10.201.108.193) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_031723_859443_9CA3325E X-CRM114-Status: GOOD ( 29.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 2 Aug 2021 10:31:58 +0800 tangbin wrote: > Hi Jonathan: > = > On 2021/8/1 0:45, Jonathan Cameron wrote: > > On Tue, 27 Jul 2021 20:52:09 +0800 > > Tang Bin wrote: > > = > >> For the function of platform_get_irq(), the example in platform.c is > >> * int irq =3D platform_get_irq(pdev, 0); > >> * if (irq < 0) > >> * return irq; > >> So the return value of zero is unnecessary to check. And move it > >> up to a little bit can simplify the code jump. > >> > >> Co-developed-by: Zhang Shengju > >> Signed-off-by: Zhang Shengju > >> Signed-off-by: Tang Bin = > > Hi, > > > > Logically it is better to keep the irq handling all together, so > > I would prefer we didn't move it. = > Got it in this place. > > > > Also, platform_get_irq() is documented as never returning 0, so the cur= rent > > code is not incorrect. As such, this looks like noise unless there is > > some plan to make use of the 0 return value? What benefit do we get fr= om > > this change? = > = > Thanks for your reply, I think the benefit of this change maybe just = > simplify the code. > = > Because the return value is never equal to 0, so the check in here is = > redundant. > = > We can make the patch like this: > = > >> --- > >> drivers/iio/adc/fsl-imx25-gcq.c | 12 ++++-------- > >> 1 file changed, 4 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx= 25-gcq.c > >> index 8cb51cf7a..d28976f21 100644 > >> --- a/drivers/iio/adc/fsl-imx25-gcq.c > >> +++ b/drivers/iio/adc/fsl-imx25-gcq.c > >> @@ -320,6 +320,10 @@ static int mx25_gcq_probe(struct platform_device = *pdev) > >> if (ret) > >> return ret; > >> = > >> + priv->irq =3D platform_get_irq(pdev, 0); > >> + if (priv->irq < 0) > >> + return priv->irq; > >> + > >> for (i =3D 0; i !=3D 4; ++i) { > >> if (!priv->vref[i]) > >> continue; > >> @@ -336,14 +340,6 @@ static int mx25_gcq_probe(struct platform_device = *pdev) > >> goto err_vref_disable; > >> } > >> = > >> - priv->irq =3D platform_get_irq(pdev, 0); > >> - if (priv->irq <=3D 0) { > >> - ret =3D priv->irq; > >> - if (!ret) > >> - ret =3D -ENXIO; > >> - goto err_clk_unprepare; > >> - } > >> - = > = > priv->irq =3D platform_get_irq(pdev, 0); > if (priv->irq < 0) { > ret =3D priv->irq; > goto err_clk_unprepare; > } > = > =A0=A0=A0 If you think this is ok, I will send V2 for you. If you think = these = > change is meaningless, OK, it's a minor tidy up, so lets go with that, or perhaps this is even tid= ier? Assuming types of ret and irq are appropriate (I've not checked!) ret =3D platform_get_irq(pdev, 0); if (ret) goto err_clk_unprepare; priv->irq =3D ret; > = > just dropped this. > = > Thanks > = > Tang Bin > = > = > = > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel