Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: qcom-geni: Fix runtime PM mismatch with child devices

We need to enable runtime PM on this i2c controller before populating
child devices with i2c_add_adapter(). Otherwise, if a child device uses
runtime PM and stays runtime PM enabled we'll get the following warning
at boot.

Enabling runtime PM for inactive device (a98000.i2c) with active children

[...]

Call trace:
pm_runtime_enable+0xd8/0xf8
geni_i2c_probe+0x440/0x460
platform_drv_probe+0x74/0xc8
[...]

Let's move the runtime PM enabling and setup to before we add the
adapter, so that this device can respond to runtime PM requests from
children.

Fixes: 37692de5d523 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Stephen Boyd and committed by
Wolfram Sang
848bd3f3 350784e7

+8 -7
+8 -7
drivers/i2c/busses/i2c-qcom-geni.c
··· 571 571 572 572 dev_dbg(&pdev->dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth); 573 573 574 - ret = i2c_add_adapter(&gi2c->adap); 575 - if (ret) { 576 - dev_err(&pdev->dev, "Error adding i2c adapter %d\n", ret); 577 - return ret; 578 - } 579 - 580 574 gi2c->suspended = 1; 581 575 pm_runtime_set_suspended(gi2c->se.dev); 582 576 pm_runtime_set_autosuspend_delay(gi2c->se.dev, I2C_AUTO_SUSPEND_DELAY); 583 577 pm_runtime_use_autosuspend(gi2c->se.dev); 584 578 pm_runtime_enable(gi2c->se.dev); 579 + 580 + ret = i2c_add_adapter(&gi2c->adap); 581 + if (ret) { 582 + dev_err(&pdev->dev, "Error adding i2c adapter %d\n", ret); 583 + pm_runtime_disable(gi2c->se.dev); 584 + return ret; 585 + } 585 586 586 587 return 0; 587 588 } ··· 591 590 { 592 591 struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev); 593 592 594 - pm_runtime_disable(gi2c->se.dev); 595 593 i2c_del_adapter(&gi2c->adap); 594 + pm_runtime_disable(gi2c->se.dev); 596 595 return 0; 597 596 } 598 597