i2c: Make return value check more accurate and explicit for devm_pinctrl_get()
authorJinjie Ruan <ruanjinjie@huawei.com>
Mon, 21 Aug 2023 03:29:14 +0000 (11:29 +0800)
committerWolfram Sang <wsa@kernel.org>
Fri, 25 Aug 2023 22:18:39 +0000 (00:18 +0200)
commitc8930ed073951105bf42c4b1d3b9520aa83debfa
tree2b4cc87c71e57fff499c63007219a29cf7bc7603
parent4ba63869a0f539c1b8d5027ccf2295c23d66fa54
i2c: Make return value check more accurate and explicit for devm_pinctrl_get()

If pinctrl is not available (thus devm_pinctrl_get() returns NULL) then
recovery can't work, because we can't switch the I2C pins between the
I2C controller and GPIO. So, it is quite correct to print
"can't get pinctrl, bus recovery not supported" because the I2C bus
can't be recovered without pinctrl.

The PTR_ERR() is also fine - because if pinctrl is not present and
returns NULL, we'll end up returning zero, which is exactly what we
want.

However, open code that with a more accurate message will be more explicit
for NULL case when CONFIG_PINCTRL is not defined.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-at91-master.c
drivers/i2c/busses/i2c-imx.c