generic: 6.1: backport QCA807x PHY patches
[openwrt/staging/jow.git] / target / linux / generic / backport-6.1 / 820-v6.4-net-phy-fix-circular-LEDS_CLASS-dependencies.patch
1 From 4bb7aac70b5d8a4bddf4ee0791b834f9f56883d2 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Thu, 20 Apr 2023 10:45:51 +0200
4 Subject: [PATCH] net: phy: fix circular LEDS_CLASS dependencies
5
6 The CONFIG_PHYLIB symbol is selected by a number of device drivers that
7 need PHY support, but it now has a dependency on CONFIG_LEDS_CLASS,
8 which may not be enabled, causing build failures.
9
10 Avoid the risk of missing and circular dependencies by guarding the
11 phylib LED support itself in another Kconfig symbol that can only be
12 enabled if the dependency is met.
13
14 This could be made a hidden symbol and always enabled when both CONFIG_OF
15 and CONFIG_LEDS_CLASS are reachable from the phylib, but there may be an
16 advantage in having users see this option when they have a misconfigured
17 kernel without built-in LED support.
18
19 Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
20 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
21 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
22 Link: https://lore.kernel.org/r/20230420084624.3005701-1-arnd@kernel.org
23 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
24 ---
25 drivers/net/phy/Kconfig | 9 ++++++++-
26 drivers/net/phy/phy_device.c | 3 ++-
27 2 files changed, 10 insertions(+), 2 deletions(-)
28
29 --- a/drivers/net/phy/Kconfig
30 +++ b/drivers/net/phy/Kconfig
31 @@ -18,7 +18,6 @@ menuconfig PHYLIB
32 depends on NETDEVICES
33 select MDIO_DEVICE
34 select MDIO_DEVRES
35 - depends on LEDS_CLASS || LEDS_CLASS=n
36 help
37 Ethernet controllers are usually attached to PHY
38 devices. This option provides infrastructure for
39 @@ -45,6 +44,14 @@ config LED_TRIGGER_PHY
40 <Speed in megabits>Mbps OR <Speed in gigabits>Gbps OR link
41 for any speed known to the PHY.
42
43 +config PHYLIB_LEDS
44 + bool "Support probing LEDs from device tree"
45 + depends on LEDS_CLASS=y || LEDS_CLASS=PHYLIB
46 + depends on OF
47 + default y
48 + help
49 + When LED class support is enabled, phylib can automatically
50 + probe LED setting from device tree.
51
52 config FIXED_PHY
53 tristate "MDIO Bus/PHY emulation with fixed speed/link PHYs"
54 --- a/drivers/net/phy/phy_device.c
55 +++ b/drivers/net/phy/phy_device.c
56 @@ -3316,7 +3316,8 @@ static int phy_probe(struct device *dev)
57 /* Get the LEDs from the device tree, and instantiate standard
58 * LEDs for them.
59 */
60 - err = of_phy_leds(phydev);
61 + if (IS_ENABLED(CONFIG_PHYLIB_LEDS))
62 + err = of_phy_leds(phydev);
63
64 out:
65 /* Re-assert the reset signal on error */