[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231207141653.2785124-2-andriy.shevchenko@linux.intel.com>
Date: Thu, 7 Dec 2023 16:13:41 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Mario Limonciello <mario.limonciello@....com>,
Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Wolfram Sang <wsa@...nel.org>,
Andi Shyti <andi.shyti@...nel.org>, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>,
Jan Dabros <jsd@...ihalf.com>,
Philipp Zabel <p.zabel@...gutronix.de>,
Serge Semin <fancer.lancer@...il.com>
Subject: [PATCH v5 01/24] i2c: designware: Fix PM calls order in dw_i2c_plat_probe()
We should not mix managed calls with non-managed. This will break
the calls order at the error path and ->remove() stages. Fix this
by wrapping PM ops to become managed one.
Reviewed-by: Andi Shyti <andi.shyti@...nel.org>
Tested-by: Serge Semin <fancer.lancer@...il.com>
Acked-by: Jarkko Nikula <jarkko.nikula@...ux.intel.com>
Link: https://lore.kernel.org/r/20231120144641.1660574-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 26 ++++++++++++++-------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 855b698e99c0..fd3cd65f9c88 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -177,14 +177,26 @@ static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev)
return 0;
}
-static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
+static void dw_i2c_plat_pm_cleanup(void *data)
{
+ struct dw_i2c_dev *dev = data;
+
pm_runtime_disable(dev->dev);
if (dev->shared_with_punit)
pm_runtime_put_noidle(dev->dev);
}
+static int dw_i2c_plat_pm_setup(struct dw_i2c_dev *dev)
+{
+ if (dev->shared_with_punit)
+ pm_runtime_get_noresume(dev->dev);
+
+ pm_runtime_enable(dev->dev);
+
+ return devm_add_action_or_reset(dev->dev, dw_i2c_plat_pm_cleanup, dev);
+}
+
static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
{
struct platform_device *pdev = to_platform_device(dev->dev);
@@ -381,19 +393,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
- if (dev->shared_with_punit)
- pm_runtime_get_noresume(&pdev->dev);
-
- pm_runtime_enable(&pdev->dev);
+ ret = dw_i2c_plat_pm_setup(dev);
+ if (ret)
+ goto exit_reset;
ret = i2c_dw_probe(dev);
if (ret)
- goto exit_probe;
+ goto exit_reset;
return ret;
-exit_probe:
- dw_i2c_plat_pm_cleanup(dev);
exit_reset:
reset_control_assert(dev->rst);
return ret;
@@ -411,7 +420,6 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_put_sync(&pdev->dev);
- dw_i2c_plat_pm_cleanup(dev);
i2c_dw_remove_lock_support(dev);
--
2.43.0.rc1.1.gbec44491f096
Powered by blists - more mailing lists