Skip to content

Commit 0345994

Browse files
jhovoldgregkh
authored andcommitted
i2c: core: fix adapter probe deferral loop
commit 158efa4 upstream. Drivers must not probe defer after having registered devices as that will trigger a probe loop if the devices bind to a driver (cf. commit fbc35b4 ("Add documentation on meaning of -EPROBE_DEFER")). Move the recovery initialisation, where the GPIO lookup may fail, before registering the adapter to prevent this. Fixes: 7582031 ("i2c: core: add generic I2C GPIO recovery") Cc: stable@vger.kernel.org # 5.9 Cc: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3351c5e commit 0345994

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/i2c/i2c-core-base.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
15621562
adap->dev.type = &i2c_adapter_type;
15631563
device_initialize(&adap->dev);
15641564

1565+
res = i2c_init_recovery(adap);
1566+
if (res == -EPROBE_DEFER)
1567+
goto err_put_adap;
1568+
15651569
/*
15661570
* This adapter can be used as a parent immediately after device_add(),
15671571
* setup runtime-pm (especially ignore-children) before hand.
@@ -1587,10 +1591,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
15871591
if (res)
15881592
goto out_reg;
15891593

1590-
res = i2c_init_recovery(adap);
1591-
if (res == -EPROBE_DEFER)
1592-
goto out_reg;
1593-
15941594
dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
15951595

15961596
/* create pre-declared device nodes */

0 commit comments

Comments
 (0)