Skip to content

Commit

Permalink
linux: I2C has this time a power state fix in the core for ACPI devic…
Browse files Browse the repository at this point in the history
…es, a

Commit: c2bf05db6c78f53ca5cd4b48f3b9b71f78d215f1
  • Loading branch information
Linus Torvalds authored and sourcegraph-bot committed Dec 3, 2022
1 parent 32f1b3f commit 46c0caa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
11 changes: 8 additions & 3 deletions linux/drivers/i2c/busses/i2c-cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US);
if (ret) {
ret = -EAGAIN;
i2c_recover_bus(adap);
if (id->adap.bus_recovery_info)
i2c_recover_bus(adap);
goto out;
}

Expand Down Expand Up @@ -1263,8 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev)

id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(id->rinfo.pinctrl)) {
int err = PTR_ERR(id->rinfo.pinctrl);

dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
return PTR_ERR(id->rinfo.pinctrl);
if (err != -ENODEV)
return err;
} else {
id->adap.bus_recovery_info = &id->rinfo;
}

id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
Expand All @@ -1283,7 +1289,6 @@ static int cdns_i2c_probe(struct platform_device *pdev)
id->adap.retries = 3; /* Default retry value. */
id->adap.algo_data = id;
id->adap.dev.parent = &pdev->dev;
id->adap.bus_recovery_info = &id->rinfo;
init_completion(&id->xfer_done);
snprintf(id->adap.name, sizeof(id->adap.name),
"Cadence I2C at %08lx", (unsigned long)r_mem->start);
Expand Down
6 changes: 4 additions & 2 deletions linux/drivers/i2c/busses/i2c-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,8 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs,
int i, result;
unsigned int temp;
int block_data = msgs->flags & I2C_M_RECV_LEN;
int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data;
int use_dma = i2c_imx->dma && msgs->flags & I2C_M_DMA_SAFE &&
msgs->len >= DMA_THRESHOLD && !block_data;

dev_dbg(&i2c_imx->adapter.dev,
"<%s> write slave address: addr=0x%x\n",
Expand Down Expand Up @@ -1298,7 +1299,8 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
result = i2c_imx_read(i2c_imx, &msgs[i], is_lastmsg, atomic);
} else {
if (!atomic &&
i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD)
i2c_imx->dma && msgs[i].len >= DMA_THRESHOLD &&
msgs[i].flags & I2C_M_DMA_SAFE)
result = i2c_imx_dma_write(i2c_imx, &msgs[i]);
else
result = i2c_imx_write(i2c_imx, &msgs[i], atomic);
Expand Down
11 changes: 10 additions & 1 deletion linux/drivers/i2c/busses/i2c-npcm7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2393,8 +2393,17 @@ static struct platform_driver npcm_i2c_bus_driver = {

static int __init npcm_i2c_init(void)
{
int ret;

npcm_i2c_debugfs_dir = debugfs_create_dir("npcm_i2c", NULL);
return platform_driver_register(&npcm_i2c_bus_driver);

ret = platform_driver_register(&npcm_i2c_bus_driver);
if (ret) {
debugfs_remove_recursive(npcm_i2c_debugfs_dir);
return ret;
}

return 0;
}
module_init(npcm_i2c_init);

Expand Down
1 change: 0 additions & 1 deletion linux/drivers/i2c/busses/i2c-qcom-geni.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], i
dev_err(gi2c->se.dev, "I2C timeout gpi flags:%d addr:0x%x\n",
gi2c->cur->flags, gi2c->cur->addr);
gi2c->err = -ETIMEDOUT;
goto err;
}

if (gi2c->err) {
Expand Down
9 changes: 5 additions & 4 deletions linux/drivers/i2c/i2c-core-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ static int i2c_device_probe(struct device *dev)
{
struct i2c_client *client = i2c_verify_client(dev);
struct i2c_driver *driver;
bool do_power_on;
int status;

if (!client)
Expand Down Expand Up @@ -545,8 +546,8 @@ static int i2c_device_probe(struct device *dev)
if (status < 0)
goto err_clear_wakeup_irq;

status = dev_pm_domain_attach(&client->dev,
!i2c_acpi_waive_d0_probe(dev));
do_power_on = !i2c_acpi_waive_d0_probe(dev);
status = dev_pm_domain_attach(&client->dev, do_power_on);
if (status)
goto err_clear_wakeup_irq;

Expand Down Expand Up @@ -585,7 +586,7 @@ static int i2c_device_probe(struct device *dev)
err_release_driver_resources:
devres_release_group(&client->dev, client->devres_group_id);
err_detach_pm_domain:
dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev));
dev_pm_domain_detach(&client->dev, do_power_on);
err_clear_wakeup_irq:
dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false);
Expand All @@ -610,7 +611,7 @@ static void i2c_device_remove(struct device *dev)

devres_release_group(&client->dev, client->devres_group_id);

dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev));
dev_pm_domain_detach(&client->dev, true);

dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false);
Expand Down

0 comments on commit 46c0caa

Please sign in to comment.