Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1280743pxy; Sun, 1 Aug 2021 19:35:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkGQKJqj2+xuHc7jkKY1dgs7eN1T+A1dTt4GFjYmAgJVChcRBQUhj1/94zxGr3wyDbHhdf X-Received: by 2002:a17:907:d06:: with SMTP id gn6mr13567982ejc.319.1627871713917; Sun, 01 Aug 2021 19:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627871713; cv=none; d=google.com; s=arc-20160816; b=EGnn9PekXVwiEmLBBdEH69fSj02u3WnHrYW0ptTRVS5RQiGSyeCzqhgdhbNU5sSUb+ 3mFsMib90QUheZX7ULs2yAZxZeL+/zHKuLw/eDGPVGg9OLfK8jB65k8daLWJEXsi8WWc dMfBDl318i6KRnV8N2K6kRTWp/zBTM81L3a2vmsx7KG5+KArjeRTxnXlfzMFC2zAbkiy /UgO/BZxGFLtEsYtlQVFq+UWoBy+JUvkrFs8Cr5jR8OD+npJkPiT/qtYp7Bf+74CUbdF FOa7ZyqG5YHhsewwiGEu15OLmGJwl8bUeLnIwCiQ3YK6YsGRLvWMJU2zHTPvGFuwejFe sytg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=cGMtgc2nDgIOtKOEoep4gpa3EPC/4EGxRXU6Vmht260=; b=pIB1U58vaKbsN0MnZQeYcI61dwB8Ri/Z1CCMAGjQpfISTWI1sK6vm8nGO5/L5uS6XB ijyCbZrReXNc5AEUJaKUCXQGAd4LaSQf+I6ZqjE1cUsCpxR9V1utLZq1yg6jb4KhepA1 eXdwPhD08OOueR0P+EUJDkYipwabBZ1NxQr18+U6zuD0J05y7N81Yvu22ZRrvn4D2dVd mkFuPlxlv0PCcXZ9yE67dLNRGn6uIlm8hqlDiheLj+I3ZyqM7V3I0phBjA7UsMiu0NEy ddsm/atKxmRHb9fuOwg6LA6Vgzpdecdeolt7v3EilMIGsMsrGEDgfRvKWHrDj1PuoPy1 u3tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si10998107ejb.600.2021.08.01.19.34.51; Sun, 01 Aug 2021 19:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbhHBCdf (ORCPT + 99 others); Sun, 1 Aug 2021 22:33:35 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:19885 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhHBCde (ORCPT ); Sun, 1 Aug 2021 22:33:34 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee961075917e6b-e0b59; Mon, 02 Aug 2021 10:31:52 +0800 (CST) X-RM-TRANSID: 2ee961075917e6b-e0b59 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [192.168.26.114] (unknown[10.42.68.12]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee861075917908-5b6c1; Mon, 02 Aug 2021 10:31:52 +0800 (CST) X-RM-TRANSID: 2ee861075917908-5b6c1 Subject: Re: [PATCH] iio: adc: fsl-imx25-gcq: fix the right check and simplify code To: Jonathan Cameron Cc: knaack.h@gmx.de, lars@metafoo.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20210727125209.28248-1-tangbin@cmss.chinamobile.com> <20210731174551.188aee79@jic23-huawei> From: tangbin Message-ID: Date: Mon, 2 Aug 2021 10:31:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20210731174551.188aee79@jic23-huawei> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = 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 current > 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 from > 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-imx25-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 = platform_get_irq(pdev, 0); >> + if (priv->irq < 0) >> + return priv->irq; >> + >> for (i = 0; i != 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 = platform_get_irq(pdev, 0); >> - if (priv->irq <= 0) { >> - ret = priv->irq; >> - if (!ret) >> - ret = -ENXIO; >> - goto err_clk_unprepare; >> - } >> - priv->irq = platform_get_irq(pdev, 0); if (priv->irq < 0) { ret = priv->irq; goto err_clk_unprepare; }     If you think this is ok, I will send V2 for you. If you think these change is meaningless, just dropped this. Thanks Tang Bin