]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: phy: move (of_)mdio_find_bus to mdio_bus_provider.c
authorHeiner Kallweit <hkallweit1@gmail.com>
Mon, 9 Mar 2026 17:04:08 +0000 (18:04 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Mar 2026 19:23:02 +0000 (12:23 -0700)
Functionality outside libphy shouldn't access mdio_bus_class directly.
So move both functions to the provider side. This is a step towards
making mdio_bus_class private to libphy.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/b6161c64-68ac-4524-82ec-5b7d81b86dbc@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_bus_provider.c

index a30c679feecaf2a6838be1f89689e0dfcd97e09b..c9a495390d26daba8d1d391d4cb8016720bbb03c 100644 (file)
@@ -276,50 +276,6 @@ const struct class mdio_bus_class = {
 };
 EXPORT_SYMBOL_GPL(mdio_bus_class);
 
-/**
- * mdio_find_bus - Given the name of a mdiobus, find the mii_bus.
- * @mdio_name: The name of a mdiobus.
- *
- * Return: a reference to the mii_bus, or NULL if none found. The
- * embedded struct device will have its reference count incremented,
- * and this must be put_deviced'ed once the bus is finished with.
- */
-struct mii_bus *mdio_find_bus(const char *mdio_name)
-{
-       struct device *d;
-
-       d = class_find_device_by_name(&mdio_bus_class, mdio_name);
-       return d ? to_mii_bus(d) : NULL;
-}
-EXPORT_SYMBOL(mdio_find_bus);
-
-#if IS_ENABLED(CONFIG_OF_MDIO)
-/**
- * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
- * @mdio_bus_np: Pointer to the mii_bus.
- *
- * Return: a reference to the mii_bus, or NULL if none found. The
- * embedded struct device will have its reference count incremented,
- * and this must be put once the bus is finished with.
- *
- * Because the association of a device_node and mii_bus is made via
- * of_mdiobus_register(), the mii_bus cannot be found before it is
- * registered with of_mdiobus_register().
- *
- */
-struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
-{
-       struct device *d;
-
-       if (!mdio_bus_np)
-               return NULL;
-
-       d = class_find_device_by_of_node(&mdio_bus_class, mdio_bus_np);
-       return d ? to_mii_bus(d) : NULL;
-}
-EXPORT_SYMBOL(of_mdio_find_bus);
-#endif
-
 static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
 {
        preempt_disable();
index 4b0637405740e789d7251f201eef93fe20db1011..d50fe6eb4b020adc24a38f2e566d69dd84db6b79 100644 (file)
@@ -440,3 +440,47 @@ void mdiobus_free(struct mii_bus *bus)
        put_device(&bus->dev);
 }
 EXPORT_SYMBOL(mdiobus_free);
+
+/**
+ * mdio_find_bus - Given the name of a mdiobus, find the mii_bus.
+ * @mdio_name: The name of a mdiobus.
+ *
+ * Return: a reference to the mii_bus, or NULL if none found. The
+ * embedded struct device will have its reference count incremented,
+ * and this must be put_deviced'ed once the bus is finished with.
+ */
+struct mii_bus *mdio_find_bus(const char *mdio_name)
+{
+       struct device *d;
+
+       d = class_find_device_by_name(&mdio_bus_class, mdio_name);
+       return d ? to_mii_bus(d) : NULL;
+}
+EXPORT_SYMBOL(mdio_find_bus);
+
+#if IS_ENABLED(CONFIG_OF_MDIO)
+/**
+ * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
+ * @mdio_bus_np: Pointer to the mii_bus.
+ *
+ * Return: a reference to the mii_bus, or NULL if none found. The
+ * embedded struct device will have its reference count incremented,
+ * and this must be put once the bus is finished with.
+ *
+ * Because the association of a device_node and mii_bus is made via
+ * of_mdiobus_register(), the mii_bus cannot be found before it is
+ * registered with of_mdiobus_register().
+ *
+ */
+struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
+{
+       struct device *d;
+
+       if (!mdio_bus_np)
+               return NULL;
+
+       d = class_find_device_by_of_node(&mdio_bus_class, mdio_bus_np);
+       return d ? to_mii_bus(d) : NULL;
+}
+EXPORT_SYMBOL(of_mdio_find_bus);
+#endif