mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
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>
This commit is contained in:
parent
4ba63869a0
commit
c8930ed073
@ -831,7 +831,11 @@ 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 (!rinfo->pinctrl) {
|
||||
dev_info(dev->dev, "pinctrl unavailable, bus recovery not supported\n");
|
||||
return 0;
|
||||
}
|
||||
if (IS_ERR(rinfo->pinctrl)) {
|
||||
dev_info(dev->dev, "can't get pinctrl, bus recovery not supported\n");
|
||||
return PTR_ERR(rinfo->pinctrl);
|
||||
}
|
||||
|
@ -1388,7 +1388,11 @@ 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 (!i2c_imx->pinctrl) {
|
||||
dev_info(&pdev->dev, "pinctrl unavailable, bus recovery not supported\n");
|
||||
return 0;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user