diff mbox series

[v2] phy: core: don't require set_mode() callback for phy_get_mode() to work

Message ID 20250209-phy-fix-set-moe-v2-1-76e248503856@linaro.org
State Accepted
Commit d58c04e305afbaa9dda7969151f06c4efe2c98b0
Headers show
Series [v2] phy: core: don't require set_mode() callback for phy_get_mode() to work | expand

Commit Message

Dmitry Baryshkov Feb. 9, 2025, 12:31 p.m. UTC
As reported by Damon Ding, the phy_get_mode() call doesn't work as
expected unless the PHY driver has a .set_mode() call. This prompts PHY
drivers to have empty stubs for .set_mode() for the sake of being able
to get the mode.

Make .set_mode() callback truly optional and update PHY's mode even if
it there is none.

Cc: Damon Ding <damon.ding@rock-chips.com>
Link: https://lore.kernel.org/r/96f8310f-93f1-4bcb-8637-137e1159ff83@rock-chips.com
Tested-by: Damon Ding <damon.ding@rock-chips.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Changes in v2:
- Fixed Damon's name in the commit message (Damon)
- Link to v1: https://lore.kernel.org/r/20250107-phy-fix-set-moe-v1-1-b3dfe9391672@linaro.org
---
 drivers/phy/phy-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


---
base-commit: ed58d103e6da15a442ff87567898768dc3a66987
change-id: 20250107-phy-fix-set-moe-d275cff5e27b

Best regards,

Comments

Vinod Koul Feb. 13, 2025, 6:17 p.m. UTC | #1
On Sun, 09 Feb 2025 14:31:45 +0200, Dmitry Baryshkov wrote:
> As reported by Damon Ding, the phy_get_mode() call doesn't work as
> expected unless the PHY driver has a .set_mode() call. This prompts PHY
> drivers to have empty stubs for .set_mode() for the sake of being able
> to get the mode.
> 
> Make .set_mode() callback truly optional and update PHY's mode even if
> it there is none.
> 
> [...]

Applied, thanks!

[1/1] phy: core: don't require set_mode() callback for phy_get_mode() to work
      commit: d58c04e305afbaa9dda7969151f06c4efe2c98b0

Best regards,
diff mbox series

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 8dfdce605a905d7f38205727151258af41f807a9..067316dfcd83a6fc8428cddd27d3b7ebfc270831 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -405,13 +405,14 @@  EXPORT_SYMBOL_GPL(phy_power_off);
 
 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
 {
-	int ret;
+	int ret = 0;
 
-	if (!phy || !phy->ops->set_mode)
+	if (!phy)
 		return 0;
 
 	mutex_lock(&phy->mutex);
-	ret = phy->ops->set_mode(phy, mode, submode);
+	if (phy->ops->set_mode)
+		ret = phy->ops->set_mode(phy, mode, submode);
 	if (!ret)
 		phy->attrs.mode = mode;
 	mutex_unlock(&phy->mutex);