Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705120

Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'

From Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
Date 2017-08-07 08:40 +0200
Message-ID <ubJRL-4Fq-7@gated-at.bofh.it> (permalink)
References <ubIsH-3VF-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.

That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
NULL. But I think this shouldn't be considered an error, so your change
is right, just the commit log is not.

> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 54a47b40546f..7e84662fe1c0 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
>  	struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
>  
>  	i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> -	if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> +	if (IS_ERR(i2c_imx->pinctrl)) {
>  		dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
>  		return PTR_ERR(i2c_imx->pinctrl);
>  	}

Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
only be called for values x where IS_ERR(x) is true. Here it is at least
surprising that an message hints to a problem but the return code is 0.

@Julia: I'm sure coccinelle can find more of those?!

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-08-07 07:10 +0200
  Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-08-07 08:40 +0200
    Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Julia Lawall <julia.lawall@lip6.fr> - 2017-08-07 09:20 +0200
      Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-08-08 08:50 +0200
        Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Julia Lawall <julia.lawall@lip6.fr> - 2017-08-08 09:10 +0200
    Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-08-08 09:50 +0200
      Re: [PATCH] i2c: imx: Remove a useless test in  'i2c_imx_init_recovery_info()' Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-08-08 10:20 +0200

csiph-web