net: phy: Allow splitting MDIO bus/device support from PHYs
Subsystems (3)
PATCH v2 1/1 net: phy: Allow splitting MDIO bus/device support from PHYs
Introduce a new configuration symbol: MDIO_DEVICE which allows building the MDIO devices and bus code, without pulling in the entire Ethernet PHY library and devices code.
PHYLIB nows select MDIO_DEVICE and the relevant Makefile files are updated to reflect that.
When MDIO_DEVICE (MDIO bus/device only) is selected, but not PHYLIB, we have mdio-bus.ko as a loadable module, and it does not have a module_exit() function because the safety of removing a bus class is unclear.
When both MDIO_DEVICE and PHYLIB are enabled, we need to assemble everything into a common loadable module: libphy.ko because of nasty circular dependencies between phy.c, phy_device.c and mdio_bus.c which are really tough to untangle.
---
Changes in v2:
- implement Russell's feedback
- solve the circular dependency in the CONFIG_MDIO_DEVICE + CONFIG_PHYLIB case
drivers/net/Makefile | 2 +- drivers/net/phy/Kconfig | 59 +++++++++++++++++++++++----------------- drivers/net/phy/Makefile | 13 +++++++-- drivers/net/phy/mdio-boardinfo.c | 1 + drivers/net/phy/mdio_bus.c | 9 ++++++ include/linux/phy.h | 21 ++++++++++++-- 6 files changed, 75 insertions(+), 30 deletions(-)
drivers/net/Makefile +1 -1
@@ -17,7 +17,7 @@ obj-$(CONFIG_MII) += mii.o obj-$(CONFIG_MDIO) += mdio.o obj-$(CONFIG_NET) += Space.o loopback.o obj-$(CONFIG_NETCONSOLE) += netconsole.o -obj-$(CONFIG_PHYLIB) += phy/ +obj-$(CONFIG_MDIO_DEVICE) += phy/ obj-$(CONFIG_RIONET) += rionet.o obj-$(CONFIG_NET_TEAM) += team/ obj-$(CONFIG_TUN) += tun.o
drivers/net/phy/Kconfig +34 -25
73 lines not on this page · raw message
drivers/net/phy/Makefile +11 -2
@@ -1,7 +1,16 @@ # Makefile for Linux PHY drivers and MDIO bus drivers -libphy-y := phy.o phy_device.o mdio_bus.o mdio_device.o \ - mdio-boardinfo.o +libphy-y := phy.o phy_device.o +mdio-bus-y += mdio_bus.o mdio_device.o mdio-boardinfo.o + +# PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular +# dependencies that does not make it possible to split mdio-bus objects into a +# dedicated loadable module, so we bundle them all together into libphy.ko +ifdef CONFIG_PHYLIB +libphy-y += $(mdio-bus-y) +else +obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o +endif libphy-$(CONFIG_SWPHY) += swphy.o libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o
drivers/net/phy/mdio-boardinfo.c +1 -0
@@ -84,3 +84,4 @@ int mdiobus_register_board_info(const struct mdio_board_info *info,return 0 ; } +EXPORT_SYMBOL (mdiobus_register_board_info);
drivers/net/phy/mdio_bus.c +9 -0
@@ -648,9 +648,18 @@ int __init mdio_bus_init(void)return ret; } +EXPORT_SYMBOL_GPL (mdio_bus_init); +#if IS_ENABLED (CONFIG_PHYLIB )void mdio_bus_exit (void ) {class_unregister (&mdio_bus_class);bus_unregister (&mdio_bus_type); } +EXPORT_SYMBOL_GPL (mdio_bus_exit); +#else +module_init (mdio_bus_init); +/* no module_exit, intentional */ +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("MDIO bus/device layer" ); +#endif
include/linux/phy.h +19 -2
@@ -779,8 +779,24 @@ void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,struct phy_device *phy_device_create (struct mii_bus *bus,int addr,int phy_id,bool is_c45,struct phy_c45_device_ids *c45_ids); +#if IS_ENABLED (CONFIG_PHYLIB )struct phy_device *get_phy_device (struct mii_bus *bus,int addr,bool is_c45);int phy_device_register (struct phy_device *phy); +void phy_device_free (struct phy_device *phydev); +#else +static inline +struct phy_device *get_phy_device (struct mii_bus *bus,int addr,bool is_c45) +{ +return NULL ; +} + +static inline int phy_device_register (struct phy_device *phy) +{ +return 0 ; +} + +static inline void phy_device_free (struct phy_device *phydev) { } +#endif /* CONFIG_PHYLIB */ void phy_device_remove (struct phy_device *phydev);int phy_init_hw (struct phy_device *phydev);int phy_suspend (struct phy_device *phydev);
@@ -854,7 +870,6 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,int phy_mii_ioctl (struct phy_device *phydev,struct ifreq *ifr,int cmd);int phy_start_interrupts (struct phy_device *phydev);void phy_print_status (struct phy_device *phydev); -void phy_device_free (struct phy_device *phydev);int phy_set_max_speed (struct phy_device *phydev,u32 max_speed); int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
@@ -881,8 +896,10 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev, const struct ethtool_link_ksettings *cmd);int phy_ethtool_nway_reset (struct net_device *ndev); +#if IS_ENABLED (CONFIG_PHYLIB )int __init mdio_bus_init (void );void mdio_bus_exit (void ); +#endif extern struct bus_type mdio_bus_type;
@@ -893,7 +910,7 @@ struct mdio_board_info {const void *platform_data; }; -#if IS_ENABLED (CONFIG_PHYLIB ) +#if IS_ENABLED (CONFIG_MDIO_DEVICE )int mdiobus_register_board_info (const struct mdio_board_info *info,unsigned int n);#else
Signature · 1 line
2.9.3
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-phy-Allow-splitting-MDIO-bus-device-support-from-PHYs/20170210-115834 config: i386-randconfig-h1-02130126 (attached as .config)…
Hi Florian,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-phy-Allow-splitting-MDIO-bus-device-support-from-PHYs/20170210-115834
config: i386-randconfig-h1-02130126 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 All errors (new ones prefixed by >>):
drivers/built-in.o: In function `unimac_mdio_remove':
>> mdio-bcm-unimac.c:(.text+0x2f6d9b): undefined reference to `mdiobus_unregister' >> mdio-bcm-unimac.c:(.text+0x2f6db0): undefined reference to `mdiobus_free' drivers/built-in.o: In function `unimac_mdio_reset': >> mdio-bcm-unimac.c:(.text+0x2f6e6a): undefined reference to `of_mdio_parse_addr' >> mdio-bcm-unimac.c:(.text+0x2f6ef7): undefined reference to `mdiobus_read' drivers/built-in.o: In function `unimac_mdio_probe': >> mdio-bcm-unimac.c:(.text+0x2f7297): undefined reference to `mdiobus_alloc_size' >> mdio-bcm-unimac.c:(.text+0x2f7320): undefined reference to `of_mdiobus_register' mdio-bcm-unimac.c:(.text+0x2f73aa): undefined reference to `mdiobus_free' drivers/built-in.o: In function `alloc_mdio_bitbang': >> (.text+0x2f7b28): undefined reference to `mdiobus_alloc_size' drivers/built-in.o: In function `free_mdio_bitbang': >> (.text+0x2f7bc1): undefined reference to `mdiobus_free'
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation