lkml.org 
[lkml]   [2021]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iio: adc: fsl-imx25-gcq: fix the right check and simplify code
On Tue, 27 Jul 2021 20:52:09 +0800
Tang Bin <tangbin@cmss.chinamobile.com> 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 <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

Hi,

Logically it is better to keep the irq handling all together, so
I would prefer we didn't move it.

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,

Jonathan

> ---
> 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;
> - }
> -
> ret = request_irq(priv->irq, mx25_gcq_irq, 0, pdev->name, priv);
> if (ret) {
> dev_err(dev, "Failed requesting IRQ\n");

\
 
 \ /
  Last update: 2021-07-31 18:44    [W:0.063 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site