RE: [PATCH -next v2] I2C: Fix return value check for devm_pinctrl_get()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Ruan Jinjie <ruanjinjie@xxxxxxxxxx>
> Sent: Wednesday, August 16, 2023 9:20 PM
> To: linux-i2c@xxxxxxxxxxxxxxx; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx; Codrin
> Ciubotariu <codrin.ciubotariu@xxxxxxxxxxxxx>; Andi Shyti
> <andi.shyti@xxxxxxxxxx>; Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>;
> Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>; Claudiu Beznea
> <claudiu.beznea@xxxxxxxxx>; Oleksij Rempel <linux@xxxxxxxxxxxxxxxx>;
> Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx>; Shawn Guo
> <shawnguo@xxxxxxxxxx>; Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>; Fabio
> Estevam <festevam@xxxxxxxxx>; dl-linux-imx <linux-imx@xxxxxxx>;
> Wolfram Sang <wsa@xxxxxxxxxx>; Linus Walleij <linus.walleij@xxxxxxxxxx>;
> Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>; Leo Li
> <leoyang.li@xxxxxxx>
> Cc: ruanjinjie@xxxxxxxxxx
> Subject: [PATCH -next v2] I2C: Fix return value check for devm_pinctrl_get()
> 
> The devm_pinctrl_get() function returns error pointers and never returns
> NULL. Update the checks accordingly.

Not exactly.  It can return NULL when CONFIG_PINCTRL is not defined.  We probably should fix that API too.

include/linux/pinctrl/consumer.h:
static inline struct pinctrl * __must_check devm_pinctrl_get(struct device *dev)
{
        return NULL;
}

Regards,
Leo
> 
> Fixes: 543aa2c4da8b ("i2c: at91: Move to generic GPIO bus recovery")
> Fixes: fd8961c5ba9e ("i2c: imx: make bus recovery through pinctrl optional")
> Signed-off-by: Ruan Jinjie <ruanjinjie@xxxxxxxxxx>
> ---
> v2:
> - Remove NULL check instead of using IS_ERR_OR_NULL() to avoid leaving
> them behind.
> - Update the commit title and message.
> ---
>  drivers/i2c/busses/i2c-at91-master.c | 2 +-
>  drivers/i2c/busses/i2c-imx.c         | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-
> at91-master.c
> index 94cff1cd527e..2bf1df5ef473 100644
> --- a/drivers/i2c/busses/i2c-at91-master.c
> +++ b/drivers/i2c/busses/i2c-at91-master.c
> @@ -831,7 +831,7 @@ static int at91_init_twi_recovery_gpio(struct
> platform_device *pdev,
>  	struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
> 
>  	rinfo->pinctrl = devm_pinctrl_get(&pdev->dev);
> -	if (!rinfo->pinctrl || IS_ERR(rinfo->pinctrl)) {
> +	if (IS_ERR(rinfo->pinctrl)) {
>  		dev_info(dev->dev, "can't get pinctrl, bus recovery not
> supported\n");
>  		return PTR_ERR(rinfo->pinctrl);
>  	}
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index
> 10e89586ca72..05d55893f04e 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1388,7 +1388,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);
>  	}
> --
> 2.34.1





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux