[PATCH v5 1/2] phy: core: Use runtime pm during configure too

From: Guido Günther
Date: Fri Apr 09 2021 - 07:40:30 EST


The phy's configure phase usually needs register access so taking the
device out of pm_runtime suspend looks useful.

There's currently two in tree drivers using runtime pm and .configure
(qualcomm/phy-qcom-qmp.c, rockchip/phy-rockchip-inno-dsidphy.c) but both
don't use the phy layers 'transparent' runtime phy_pm_runtime handling
but manage it manually so this will for now only affect the
phy-fsl-imx8-mipi-dphy driver.

Signed-off-by: Guido Günther <agx@xxxxxxxxxxx>
---
drivers/phy/phy-core.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ccb575b13777..256a964d52d3 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union phy_configure_opts *opts)
if (!phy->ops->configure)
return -EOPNOTSUPP;

+ ret = phy_pm_runtime_get_sync(phy);
+ if (ret < 0 && ret != -ENOTSUPP)
+ return ret;
+ ret = 0; /* Override possible ret == -ENOTSUPP */
+
mutex_lock(&phy->mutex);
ret = phy->ops->configure(phy, opts);
mutex_unlock(&phy->mutex);

+ phy_pm_runtime_put(phy);
return ret;
}
EXPORT_SYMBOL_GPL(phy_configure);
--
2.30.1