Skip to content

Commit 3c3dd56

Browse files
avolmat-stwsakernel
authored andcommitted
i2c: fix missing pm_runtime_put_sync in i2c_device_probe
In case of the I2C client exposes the flag I2C_CLIENT_HOST_NOTIFY, pm_runtime_get_sync is called in order to always keep active the adapter. However later on, pm_runtime_put_sync is never called within the function in case of an error. This commit add this error handling. Fixes: 72bfcee ("i2c: Prevent runtime suspend of adapter when Host Notify is required") Signed-off-by: Alain Volmat <[email protected]> Reviewed-by: Jarkko Nikula <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 0e698df commit 3c3dd56

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
338338
} else if (ACPI_COMPANION(dev)) {
339339
irq = i2c_acpi_get_irq(client);
340340
}
341-
if (irq == -EPROBE_DEFER)
342-
return irq;
341+
if (irq == -EPROBE_DEFER) {
342+
status = irq;
343+
goto put_sync_adapter;
344+
}
343345

344346
if (irq < 0)
345347
irq = 0;
@@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
353355
*/
354356
if (!driver->id_table &&
355357
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
356-
!i2c_of_match_device(dev->driver->of_match_table, client))
357-
return -ENODEV;
358+
!i2c_of_match_device(dev->driver->of_match_table, client)) {
359+
status = -ENODEV;
360+
goto put_sync_adapter;
361+
}
358362

359363
if (client->flags & I2C_CLIENT_WAKE) {
360364
int wakeirq;
361365

362366
wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
363-
if (wakeirq == -EPROBE_DEFER)
364-
return wakeirq;
367+
if (wakeirq == -EPROBE_DEFER) {
368+
status = wakeirq;
369+
goto put_sync_adapter;
370+
}
365371

366372
device_init_wakeup(&client->dev, true);
367373

@@ -408,6 +414,10 @@ static int i2c_device_probe(struct device *dev)
408414
err_clear_wakeup_irq:
409415
dev_pm_clear_wake_irq(&client->dev);
410416
device_init_wakeup(&client->dev, false);
417+
put_sync_adapter:
418+
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
419+
pm_runtime_put_sync(&client->adapter->dev);
420+
411421
return status;
412422
}
413423

0 commit comments

Comments
 (0)