]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: move registering mdio_bus_class and mdio_bus_type to libphy
authorHeiner Kallweit <hkallweit1@gmail.com>
Mon, 9 Mar 2026 17:04:46 +0000 (18:04 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Mar 2026 19:23:02 +0000 (12:23 -0700)
The MDIO consumer side shouldn't register class and bus_type.
Therefore move this to libphy.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/b15b378a-fda2-44b9-9d63-bf82919b71b2@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/mdio_bus.c
drivers/net/phy/phy_device.c

index c9a495390d26daba8d1d391d4cb8016720bbb03c..9fb473326027b7867f156104253f6e2386d3f5f0 100644 (file)
@@ -905,28 +905,5 @@ const struct bus_type mdio_bus_type = {
 };
 EXPORT_SYMBOL(mdio_bus_type);
 
-static int __init mdio_bus_init(void)
-{
-       int ret;
-
-       ret = class_register(&mdio_bus_class);
-       if (!ret) {
-               ret = bus_register(&mdio_bus_type);
-               if (ret)
-                       class_unregister(&mdio_bus_class);
-       }
-
-       return ret;
-}
-
-static void __exit mdio_bus_exit(void)
-{
-       class_unregister(&mdio_bus_class);
-       bus_unregister(&mdio_bus_type);
-}
-
-subsys_initcall(mdio_bus_init);
-module_exit(mdio_bus_exit);
-
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("MDIO bus/device layer");
index d1cbcfc3d2a66a28904a53b2b00fcb2e5b920c98..0edff47478c20dd8537d4b94806be13b2409c711 100644 (file)
@@ -3913,6 +3913,14 @@ static int __init phy_init(void)
 {
        int rc;
 
+       rc = class_register(&mdio_bus_class);
+       if (rc)
+               return rc;
+
+       rc = bus_register(&mdio_bus_type);
+       if (rc)
+               goto err_class;
+
        rtnl_lock();
        ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops);
        phylib_register_stubs();
@@ -3941,6 +3949,9 @@ err_ethtool_phy_ops:
        phylib_unregister_stubs();
        ethtool_set_ethtool_phy_ops(NULL);
        rtnl_unlock();
+       bus_unregister(&mdio_bus_type);
+err_class:
+       class_unregister(&mdio_bus_class);
 
        return rc;
 }
@@ -3953,6 +3964,8 @@ static void __exit phy_exit(void)
        phylib_unregister_stubs();
        ethtool_set_ethtool_phy_ops(NULL);
        rtnl_unlock();
+       bus_unregister(&mdio_bus_type);
+       class_unregister(&mdio_bus_class);
 }
 
 subsys_initcall(phy_init);