Skip to content

Commit 31be641

Browse files
hkallweitPaolo Abeni
authored and
Paolo Abeni
committed
net: phy: make mdio consumer / device layer a separate module
After having factored out the provider part from mdio_bus.c, we can make the mdio consumer / device layer a separate module. This also allows to remove Kconfig symbol MDIO_DEVICE. The module init / exit functions from mdio_bus.c no longer have to be called from phy_device.c. The link order defined in drivers/net/phy/Makefile ensures that init / exit functions are called in the right order. Signed-off-by: Heiner Kallweit <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent f685204 commit 31be641

File tree

7 files changed

+17
-48
lines changed

7 files changed

+17
-48
lines changed

drivers/net/mdio/Kconfig

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,10 @@
33
# MDIO Layer Configuration
44
#
55

6-
menuconfig MDIO_DEVICE
7-
tristate "MDIO bus device drivers"
8-
help
9-
MDIO devices and driver infrastructure code.
10-
11-
if MDIO_DEVICE
12-
136
config MDIO_BUS
14-
tristate
15-
default m if PHYLIB=m
16-
default MDIO_DEVICE
7+
tristate "MDIO bus consumer layer"
178
help
18-
This internal symbol is used for link time dependencies and it
19-
reflects whether the mdio_bus/mdio_device code is built as a
20-
loadable module or built-in.
9+
MDIO bus consumer layer
2110

2211
if PHYLIB
2312

@@ -291,4 +280,3 @@ config MDIO_BUS_MUX_MMIOREG
291280

292281

293282
endif
294-
endif

drivers/net/phy/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config PHYLINK
1414

1515
menuconfig PHYLIB
1616
tristate "PHY Device support and infrastructure"
17-
select MDIO_DEVICE
17+
select MDIO_BUS
1818
help
1919
Ethernet controllers are usually attached to PHY
2020
devices. This option provides infrastructure for

drivers/net/phy/Makefile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,19 @@ libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
66
phy_package.o phy_caps.o mdio_bus_provider.o
77
mdio-bus-y += mdio_bus.o mdio_device.o
88

9-
ifdef CONFIG_MDIO_DEVICE
10-
obj-y += mdio-boardinfo.o
11-
endif
12-
13-
# PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular
14-
# dependencies that does not make it possible to split mdio-bus objects into a
15-
# dedicated loadable module, so we bundle them all together into libphy.ko
169
ifdef CONFIG_PHYLIB
17-
libphy-y += $(mdio-bus-y)
18-
# the stubs are built-in whenever PHYLIB is built-in or module
19-
obj-y += stubs.o
20-
else
21-
obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o
10+
# built-in whenever PHYLIB is built-in or module
11+
obj-y += stubs.o mdio-boardinfo.o
2212
endif
23-
obj-$(CONFIG_PHYLIB) += mdio_devres.o
13+
2414
libphy-$(CONFIG_SWPHY) += swphy.o
2515
libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o
2616
libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) += open_alliance_helpers.o
2717

18+
obj-$(CONFIG_MDIO_BUS) += mdio-bus.o
2819
obj-$(CONFIG_PHYLINK) += phylink.o
2920
obj-$(CONFIG_PHYLIB) += libphy.o
21+
obj-$(CONFIG_PHYLIB) += mdio_devres.o
3022

3123
obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
3224

drivers/net/phy/mdio_bus.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ const struct bus_type mdio_bus_type = {
988988
};
989989
EXPORT_SYMBOL(mdio_bus_type);
990990

991-
int __init mdio_bus_init(void)
991+
static int __init mdio_bus_init(void)
992992
{
993993
int ret;
994994

@@ -1002,16 +1002,14 @@ int __init mdio_bus_init(void)
10021002
return ret;
10031003
}
10041004

1005-
#if IS_ENABLED(CONFIG_PHYLIB)
1006-
void mdio_bus_exit(void)
1005+
static void __exit mdio_bus_exit(void)
10071006
{
10081007
class_unregister(&mdio_bus_class);
10091008
bus_unregister(&mdio_bus_type);
10101009
}
1011-
EXPORT_SYMBOL_GPL(mdio_bus_exit);
1012-
#else
1013-
module_init(mdio_bus_init);
1014-
/* no module_exit, intentional */
1010+
1011+
subsys_initcall(mdio_bus_init);
1012+
module_exit(mdio_bus_exit);
1013+
10151014
MODULE_LICENSE("GPL");
10161015
MODULE_DESCRIPTION("MDIO bus/device layer");
1017-
#endif

drivers/net/phy/mdio_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int mdio_device_bus_match(struct device *dev, const struct device_driver *drv)
4545

4646
return strcmp(mdiodev->modalias, drv->name) == 0;
4747
}
48+
EXPORT_SYMBOL_GPL(mdio_device_bus_match);
4849

4950
struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr)
5051
{

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,19 +3557,15 @@ static int __init phy_init(void)
35573557
phylib_register_stubs();
35583558
rtnl_unlock();
35593559

3560-
rc = mdio_bus_init();
3561-
if (rc)
3562-
goto err_ethtool_phy_ops;
3563-
35643560
rc = phy_caps_init();
35653561
if (rc)
3566-
goto err_mdio_bus;
3562+
goto err_ethtool_phy_ops;
35673563

35683564
features_init();
35693565

35703566
rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE);
35713567
if (rc)
3572-
goto err_mdio_bus;
3568+
goto err_ethtool_phy_ops;
35733569

35743570
rc = phy_driver_register(&genphy_driver, THIS_MODULE);
35753571
if (rc)
@@ -3579,8 +3575,6 @@ static int __init phy_init(void)
35793575

35803576
err_c45:
35813577
phy_driver_unregister(&genphy_c45_driver);
3582-
err_mdio_bus:
3583-
mdio_bus_exit();
35843578
err_ethtool_phy_ops:
35853579
rtnl_lock();
35863580
phylib_unregister_stubs();
@@ -3594,7 +3588,6 @@ static void __exit phy_exit(void)
35943588
{
35953589
phy_driver_unregister(&genphy_c45_driver);
35963590
phy_driver_unregister(&genphy_driver);
3597-
mdio_bus_exit();
35983591
rtnl_lock();
35993592
phylib_unregister_stubs();
36003593
ethtool_set_ethtool_phy_ops(NULL);

include/linux/phy.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,9 +2033,6 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
20332033
const struct ethtool_link_ksettings *cmd);
20342034
int phy_ethtool_nway_reset(struct net_device *ndev);
20352035

2036-
int __init mdio_bus_init(void);
2037-
void mdio_bus_exit(void);
2038-
20392036
int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
20402037
int phy_ethtool_get_sset_count(struct phy_device *phydev);
20412038
int phy_ethtool_get_stats(struct phy_device *phydev,

0 commit comments

Comments
 (0)