1
0
Fork 0

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: 72bfcee11c ("i2c: Prevent runtime suspend of adapter when Host Notify is required")
Signed-off-by: Alain Volmat <alain.volmat@st.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
alistair/sunxi64-5.7-dsi
Alain Volmat 2020-04-30 17:43:21 +02:00 committed by Wolfram Sang
parent 0e698dfa28
commit 3c3dd56f76
1 changed files with 16 additions and 6 deletions

View File

@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
} else if (ACPI_COMPANION(dev)) { } else if (ACPI_COMPANION(dev)) {
irq = i2c_acpi_get_irq(client); irq = i2c_acpi_get_irq(client);
} }
if (irq == -EPROBE_DEFER) if (irq == -EPROBE_DEFER) {
return irq; status = irq;
goto put_sync_adapter;
}
if (irq < 0) if (irq < 0)
irq = 0; irq = 0;
@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
*/ */
if (!driver->id_table && if (!driver->id_table &&
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) && !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
!i2c_of_match_device(dev->driver->of_match_table, client)) !i2c_of_match_device(dev->driver->of_match_table, client)) {
return -ENODEV; status = -ENODEV;
goto put_sync_adapter;
}
if (client->flags & I2C_CLIENT_WAKE) { if (client->flags & I2C_CLIENT_WAKE) {
int wakeirq; int wakeirq;
wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
if (wakeirq == -EPROBE_DEFER) if (wakeirq == -EPROBE_DEFER) {
return wakeirq; status = wakeirq;
goto put_sync_adapter;
}
device_init_wakeup(&client->dev, true); device_init_wakeup(&client->dev, true);
@ -408,6 +414,10 @@ err_detach_pm_domain:
err_clear_wakeup_irq: err_clear_wakeup_irq:
dev_pm_clear_wake_irq(&client->dev); dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false); device_init_wakeup(&client->dev, false);
put_sync_adapter:
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
pm_runtime_put_sync(&client->adapter->dev);
return status; return status;
} }