Skip to contentSkip to conversation

net: phy: make PHY fixup support always built-in

PATCH New Heiner Kallweit 1 participant 1 message Jan 24

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH v2 1/1 net: phy: make PHY fixup support always built-in

PHY fixup registration is used from platform code in init phase only. Let's move the PHY fixup code from the modular part of phylib to the always built-in part of phylib. This allows to annotate the fixup registration as __init.

phy_needs_fixup() and phy_scan_fixups() wouldn't have to be moved to the built-in part of phylib. But doing so allows to fully factor out legacy fixup support into its own source code file, and make struct phy_fixup and phy_fixup_list strictly private to phy_fixup.c.

phy_scan_fixups() is used after init phase only, then phy_fixup_list is read-only. So we don't need the mutex when accessing the list. Also when registering PHY fixups the mutex isn't needed, because fixup registration is done sequentially from platform init code. Actually there is only one platform with more than one fixup.

In addition this change lays the foundation for enabling modular phylib on platforms where the fixup just sets a flag.

---
v2:
- document return value of phy_register_fixup

---
 drivers/net/phy/Makefile          |   2 +-
 drivers/net/phy/phy_device.c      |  90 --------------------------
 drivers/net/phy/phy_fixup.c       | 102 ++++++++++++++++++++++++++++++
 drivers/net/phy/phylib-internal.h |   1 +
 include/linux/phy.h               |   8 +--
 5 files changed, 108 insertions(+), 95 deletions(-)
 create mode 100644 drivers/net/phy/phy_fixup.c
drivers/net/phy/Makefile +1 -1
index 3a34917adea..52bbb441e87 100644
@@ -8,7 +8,7 @@ mdio-bus-y			+= mdio_bus.o mdio_device.o
 
 ifdef CONFIG_PHYLIB
 # built-in whenever PHYLIB is built-in or module
-obj-y				+= stubs.o
+obj-y				+= stubs.o phy_fixup.o
 endif
 
 libphy-$(CONFIG_SWPHY)		+= swphy.o
drivers/net/phy/phy_device.c +0 -90

108 lines not on this page · raw message

drivers/net/phy/phy_fixup.c new file +102 -0

102 lines not on this page · raw message

drivers/net/phy/phylib-internal.h +1 -0
index dc9592c6bb8..ca3794ffe04 100644
@@ -19,6 +19,7 @@ void of_set_phy_eee_broken(struct phy_device *phydev);
 void of_set_phy_timing_role(struct phy_device *phydev);
 int phy_speed_down_core(struct phy_device *phydev);
 void phy_check_downshift(struct phy_device *phydev);
+int phy_scan_fixups(struct phy_device *phydev);
 
 int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv);
 
include/linux/phy.h +4 -4
index 6f9979a2689..7d72def300b 100644
@@ -2401,10 +2401,10 @@ int phy_get_mac_termination(struct phy_device *phydev, struct device *dev,
 void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
 		       bool *tx_pause, bool *rx_pause);
 
-int phy_register_fixup_for_id(const char *bus_id,
-			      int (*run)(struct phy_device *));
-int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
-			       int (*run)(struct phy_device *));
+int __init phy_register_fixup_for_id(const char *bus_id,
+				     int (*run)(struct phy_device *));
+int __init phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+				      int (*run)(struct phy_device *));
 
 int phy_eee_tx_clock_stop_capable(struct phy_device *phydev);
 int phy_eee_rx_clock_stop(struct phy_device *phydev, bool clk_stop_enable);
Signature · 1 line
2.52.0