Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

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>

authored by

Dmitry Baryshkov and committed by
Vinod Koul
d58c04e3 13c1eb1b

+4 -3
+4 -3
drivers/phy/phy-core.c
··· 405 405 406 406 int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) 407 407 { 408 - int ret; 408 + int ret = 0; 409 409 410 - if (!phy || !phy->ops->set_mode) 410 + if (!phy) 411 411 return 0; 412 412 413 413 mutex_lock(&phy->mutex); 414 - ret = phy->ops->set_mode(phy, mode, submode); 414 + if (phy->ops->set_mode) 415 + ret = phy->ops->set_mode(phy, mode, submode); 415 416 if (!ret) 416 417 phy->attrs.mode = mode; 417 418 mutex_unlock(&phy->mutex);