Skip to content

Commit

Permalink
net: phy: fix circular LEDS_CLASS dependencies
Browse files Browse the repository at this point in the history
The CONFIG_PHYLIB symbol is selected by a number of device drivers that
need PHY support, but it now has a dependency on CONFIG_LEDS_CLASS,
which may not be enabled, causing build failures.

Avoid the risk of missing and circular dependencies by guarding the
phylib LED support itself in another Kconfig symbol that can only be
enabled if the dependency is met.

This could be made a hidden symbol and always enabled when both CONFIG_OF
and CONFIG_LEDS_CLASS are reachable from the phylib, but there may be an
advantage in having users see this option when they have a misconfigured
kernel without built-in LED support.

Fixes: 01e5b72 ("net: phy: Add a binding for PHY LEDs")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20230420084624.3005701-1-arnd@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Arnd Bergmann authored and Jakub Kicinski committed Apr 21, 2023
1 parent 681c5b5 commit 4bb7aac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion drivers/net/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ menuconfig PHYLIB
depends on NETDEVICES
select MDIO_DEVICE
select MDIO_DEVRES
depends on LEDS_CLASS || LEDS_CLASS=n
help
Ethernet controllers are usually attached to PHY
devices. This option provides infrastructure for
Expand All @@ -45,6 +44,14 @@ config LED_TRIGGER_PHY
<Speed in megabits>Mbps OR <Speed in gigabits>Gbps OR link
for any speed known to the PHY.

config PHYLIB_LEDS
bool "Support probing LEDs from device tree"
depends on LEDS_CLASS=y || LEDS_CLASS=PHYLIB
depends on OF
default y
help
When LED class support is enabled, phylib can automatically
probe LED setting from device tree.

config FIXED_PHY
tristate "MDIO Bus/PHY emulation with fixed speed/link PHYs"
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,8 @@ static int phy_probe(struct device *dev)
/* Get the LEDs from the device tree, and instantiate standard
* LEDs for them.
*/
err = of_phy_leds(phydev);
if (IS_ENABLED(CONFIG_PHYLIB_LEDS))
err = of_phy_leds(phydev);

out:
/* Re-assert the reset signal on error */
Expand Down

0 comments on commit 4bb7aac

Please sign in to comment.