]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: make mdio_device.c part of libphy
authorHeiner Kallweit <hkallweit1@gmail.com>
Mon, 9 Mar 2026 17:03:31 +0000 (18:03 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Mar 2026 19:23:02 +0000 (12:23 -0700)
This patch
- makes mdio_device.c part of libphy
- makes mdio_device_(un)register_reset() static
- moves mdiobus_(un)register_device() from mdio_bus.c to mdio_device.c,
  stops exporting both functions and makes them private to phylib

This further decouples the MDIO consumer functionality from libphy.

Note: This makes MDIO driver registration part of phylib, therefore
      adjust Kconfig dependencies where needed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/c6dbf9b3-3ca0-434b-ad3a-71fe602ab809@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/clk/qcom/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/mdio-private.h [deleted file]
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_device.c
drivers/net/phy/phylib-internal.h
drivers/phy/broadcom/Kconfig
include/linux/mdio.h

index a8a86ea6bb7445e396048a5bba23fce8d719281f..a277c434d641571dfc28b236dba7ec4b1ca318be 100644 (file)
@@ -392,7 +392,7 @@ config IPQ_NSSCC_9574
 
 config IPQ_NSSCC_QCA8K
        tristate "QCA8K(QCA8386 or QCA8084) NSS Clock Controller"
-       depends on MDIO_BUS
+       depends on PHYLIB
        help
          Support for NSS(Network SubSystem) clock controller on
          qca8386/qca8084 chip.
index 3a34917adea72d03342a8a4ef703ee5d087d229e..8d262b4e2be281696298bf24953ec3e24b27697a 100644 (file)
@@ -3,8 +3,8 @@
 
 libphy-y                       := phy.o phy-c45.o phy-core.o phy_device.o \
                                   linkmode.o phy_link_topology.o \
-                                  phy_caps.o mdio_bus_provider.o phy_port.o
-mdio-bus-y                     += mdio_bus.o mdio_device.o
+                                  phy_caps.o mdio_bus_provider.o phy_port.o \
+                                  mdio_device.o
 
 ifdef CONFIG_PHYLIB
 # built-in whenever PHYLIB is built-in or module
@@ -15,7 +15,7 @@ libphy-$(CONFIG_SWPHY)                += swphy.o
 libphy-$(CONFIG_LED_TRIGGER_PHY)       += phy_led_triggers.o
 libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) += open_alliance_helpers.o
 
-obj-$(CONFIG_MDIO_BUS)         += mdio-bus.o
+obj-$(CONFIG_MDIO_BUS)         += mdio_bus.o
 obj-$(CONFIG_PHYLINK)          += phylink.o
 obj-$(CONFIG_PHYLIB)           += libphy.o
 obj-$(CONFIG_PHYLIB)           += mdio_devres.o
diff --git a/drivers/net/phy/mdio-private.h b/drivers/net/phy/mdio-private.h
deleted file mode 100644 (file)
index 8bc6d90..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef __MDIO_PRIVATE_H
-#define __MDIO_PRIVATE_H
-
-/* MDIO internal helpers
- */
-
-int mdio_device_register_reset(struct mdio_device *mdiodev);
-void mdio_device_unregister_reset(struct mdio_device *mdiodev);
-
-#endif /* __MDIO_PRIVATE_H */
index 48c0447e6a8f7a3a642fef32f2a18c7ebde8cb85..a30c679feecaf2a6838be1f89689e0dfcd97e09b 100644 (file)
 #include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
-#include "mdio-private.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/mdio.h>
 
-int mdiobus_register_device(struct mdio_device *mdiodev)
-{
-       int err;
-
-       if (mdiodev->bus->mdio_map[mdiodev->addr])
-               return -EBUSY;
-
-       if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) {
-               err = mdio_device_register_reset(mdiodev);
-               if (err)
-                       return err;
-
-               /* Assert the reset signal */
-               mdio_device_reset(mdiodev, 1);
-       }
-
-       mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev;
-
-       return 0;
-}
-EXPORT_SYMBOL(mdiobus_register_device);
-
-int mdiobus_unregister_device(struct mdio_device *mdiodev)
-{
-       if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
-               return -EINVAL;
-
-       mdio_device_unregister_reset(mdiodev);
-
-       mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
-
-       return 0;
-}
-EXPORT_SYMBOL(mdiobus_unregister_device);
-
 static struct mdio_device *mdiobus_find_device(struct mii_bus *bus, int addr)
 {
        bool addr_valid = addr >= 0 && addr < ARRAY_SIZE(bus->mdio_map);
index da4fb7484c7c77d456445bff3d0aa88f9f7e6409..56080d3d2d25e6ba832c7741c05d15da510ee079 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/string.h>
 #include <linux/unistd.h>
 #include <linux/property.h>
-#include "mdio-private.h"
+#include "phylib-internal.h"
 
 /**
  * mdio_device_register_reset - Read and initialize the reset properties of
@@ -31,7 +31,7 @@
  *
  * Return: Zero if successful, negative error code on failure
  */
-int mdio_device_register_reset(struct mdio_device *mdiodev)
+static int mdio_device_register_reset(struct mdio_device *mdiodev)
 {
        struct reset_control *reset;
 
@@ -67,7 +67,7 @@ int mdio_device_register_reset(struct mdio_device *mdiodev)
  *                               an mdio device
  * @mdiodev: mdio_device structure
  */
-void mdio_device_unregister_reset(struct mdio_device *mdiodev)
+static void mdio_device_unregister_reset(struct mdio_device *mdiodev)
 {
        gpiod_put(mdiodev->reset_gpio);
        mdiodev->reset_gpio = NULL;
@@ -189,6 +189,39 @@ void mdio_device_remove(struct mdio_device *mdiodev)
 }
 EXPORT_SYMBOL(mdio_device_remove);
 
+int mdiobus_register_device(struct mdio_device *mdiodev)
+{
+       int err;
+
+       if (mdiodev->bus->mdio_map[mdiodev->addr])
+               return -EBUSY;
+
+       if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) {
+               err = mdio_device_register_reset(mdiodev);
+               if (err)
+                       return err;
+
+               /* Assert the reset signal */
+               mdio_device_reset(mdiodev, 1);
+       }
+
+       mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev;
+
+       return 0;
+}
+
+int mdiobus_unregister_device(struct mdio_device *mdiodev)
+{
+       if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
+               return -EINVAL;
+
+       mdio_device_unregister_reset(mdiodev);
+
+       mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
+
+       return 0;
+}
+
 /**
  * mdio_probe - probe an MDIO device
  * @dev: device to probe
index dc9592c6bb8e7b5140227a2b362d8d29f2bf5ee7..bfb1aa8238686d18e3bc81d01e6ff8ec68402294 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef __PHYLIB_INTERNAL_H
 #define __PHYLIB_INTERNAL_H
 
+struct mdio_device;
 struct phy_device;
 
 /*
@@ -20,6 +21,9 @@ 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 mdiobus_register_device(struct mdio_device *mdiodev);
+int mdiobus_unregister_device(struct mdio_device *mdiodev);
+
 int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv);
 
 #endif /* __PHYLIB_INTERNAL_H */
index 1d89a2fd9b79b328ec5299fffaf97a12f6b34243..46371a8940d76fba514a04739865020fa86de5c5 100644 (file)
@@ -52,7 +52,7 @@ config PHY_BCM_NS_USB3
        tristate "Broadcom Northstar USB 3.0 PHY Driver"
        depends on ARCH_BCM_IPROC || COMPILE_TEST
        depends on HAS_IOMEM && OF
-       depends on MDIO_BUS
+       depends on PHYLIB
        select GENERIC_PHY
        help
          Enable this to support Broadcom USB 3.0 PHY connected to the USB
@@ -60,7 +60,7 @@ config PHY_BCM_NS_USB3
 
 config PHY_NS2_PCIE
        tristate "Broadcom Northstar2 PCIe PHY driver"
-       depends on (OF && MDIO_BUS_MUX_BCM_IPROC) || (COMPILE_TEST && MDIO_BUS)
+       depends on (OF && MDIO_BUS_MUX_BCM_IPROC) || (COMPILE_TEST && PHYLIB)
        select GENERIC_PHY
        default ARCH_BCM_IPROC
        help
index 5d1203b9af205c024f899014e7e5e403fad6b35c..f4f9d96094488e44882780fff2e8bdfcd500f0df 100644 (file)
@@ -688,8 +688,6 @@ static inline int mdiodev_c45_write(struct mdio_device *mdiodev, u32 devad,
                                 val);
 }
 
-int mdiobus_register_device(struct mdio_device *mdiodev);
-int mdiobus_unregister_device(struct mdio_device *mdiodev);
 bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
 struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr);