Skip to content

Commit 225a3ca

Browse files
Dmitry Baryshkovopsiff
authored andcommitted
phy: core: don't require set_mode() callback for phy_get_mode() to work
[ Upstream commit d58c04e ] 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> Link: https://lore.kernel.org/r/20250209-phy-fix-set-moe-v2-1-76e248503856@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 6a7b7e98fec0aedcc413f53255359041dbc54c28)
1 parent 820d364 commit 225a3ca

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/phy/phy-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,14 @@ EXPORT_SYMBOL_GPL(phy_power_off);
400400

401401
int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
402402
{
403-
int ret;
403+
int ret = 0;
404404

405-
if (!phy || !phy->ops->set_mode)
405+
if (!phy)
406406
return 0;
407407

408408
mutex_lock(&phy->mutex);
409-
ret = phy->ops->set_mode(phy, mode, submode);
409+
if (phy->ops->set_mode)
410+
ret = phy->ops->set_mode(phy, mode, submode);
410411
if (!ret)
411412
phy->attrs.mode = mode;
412413
mutex_unlock(&phy->mutex);

0 commit comments

Comments
 (0)