diff mbox series

[2/2] phy: core: Warn when phy_power_on is called before phy_init

Message ID 20220322143011.16580-3-jmaselbas@kalray.eu
State Superseded
Headers show
Series [1/2] phy: core: Add documentation of phy operation order | expand

Commit Message

Jules Maselbas March 22, 2022, 2:30 p.m. UTC
A warning when the order of phy operation is mixed up by drivers,
this is an atempt to make the phy usage more uniform across (usb)
drivers.

CC: Ahmad Fatoum <a.fatoum@pengutronix.de>
CC: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/phy/phy-core.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ed10cbb24b08..2c2c0f073080 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -252,6 +252,9 @@  int phy_init(struct phy *phy)
 		return ret;
 	ret = 0; /* Override possible ret == -ENOTSUPP */
 
+	if (phy->power_count > phy->init_count)
+		dev_warn(&phy->dev, "phy_power_on was called before phy_init\n");
+
 	mutex_lock(&phy->mutex);
 	if (phy->init_count == 0 && phy->ops->init) {
 		ret = phy->ops->init(phy);