diff mbox series

[3/4] i2c: i2c-cadence: Reset pinctrl to NULL in case devm_pinctrl_get() fails

Message ID 20230816200410.62131-4-yann@sionneau.net
State Needs Review / ACK
Headers show
Series i2c: devm_pinctrl_get() usage fixes | expand

Commit Message

Yann Sionneau Aug. 16, 2023, 8:04 p.m. UTC
The core i2c code generally checks if pinctrl has been properly initialized
by just doing 'if (p) some_pinctrl_function(p)'.
In case devm_pinctrl_get() fails, pinctrl variable contains an error
instead of a valid pointer.
To prevent core i2c code to crash, reset back pinctrl pointer to NULL when
this happens.

Signed-off-by: Yann Sionneau <yann@sionneau.net>
---
 drivers/i2c/busses/i2c-cadence.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 9849f4502570..aa9ae0755674 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -1299,6 +1299,7 @@  static int cdns_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(id->rinfo.pinctrl)) {
 		int err = PTR_ERR(id->rinfo.pinctrl);
 
+		id->rinfo.pinctrl = NULL;
 		dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
 		if (err != -ENODEV)
 			return err;