From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH net-next 2/5] net: phy: make mdio_device.c part of libphy
Date: Sat, 7 Mar 2026 22:32:00 +0100 [thread overview]
Message-ID: <8600cf79-7604-43c1-8cc0-306e58e31153@gmail.com> (raw)
In-Reply-To: <8b34944e-3abf-4dd1-908d-c21d08c62c34@gmail.com>
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/Makefile | 6 ++---
drivers/net/phy/mdio-private.h | 11 ---------
drivers/net/phy/mdio_bus.c | 36 ----------------------------
drivers/net/phy/mdio_device.c | 39 ++++++++++++++++++++++++++++---
drivers/net/phy/phylib-internal.h | 4 ++++
include/linux/mdio.h | 2 --
6 files changed, 43 insertions(+), 55 deletions(-)
delete mode 100644 drivers/net/phy/mdio-private.h
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 3a34917adea..8d262b4e2be 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -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
index 8bc6d9088af..00000000000
--- a/drivers/net/phy/mdio-private.h
+++ /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 */
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 48c0447e6a8..a30c679feec 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -29,46 +29,10 @@
#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);
diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index da4fb7484c7..56080d3d2d2 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -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
diff --git a/drivers/net/phy/phylib-internal.h b/drivers/net/phy/phylib-internal.h
index dc9592c6bb8..bfb1aa82386 100644
--- a/drivers/net/phy/phylib-internal.h
+++ b/drivers/net/phy/phylib-internal.h
@@ -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 */
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 5d1203b9af2..f4f9d960944 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -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);
--
2.53.0
next prev parent reply other threads:[~2026-03-07 21:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 21:30 [PATCH net-next 0/5] net: phy: further decouple provider from consumer part Heiner Kallweit
2026-03-07 21:31 ` [PATCH net-next 1/5] net: phy: move mdio_device reset handling functions in the code Heiner Kallweit
2026-03-07 21:32 ` Heiner Kallweit [this message]
2026-03-08 13:15 ` [PATCH net-next 2/5] net: phy: make mdio_device.c part of libphy kernel test robot
2026-03-07 21:32 ` [PATCH net-next 3/5] net: phy: move (of_)mdio_find_bus to mdio_bus_provider.c Heiner Kallweit
2026-03-07 21:33 ` [PATCH net-next 4/5] net: phy: move registering mdio_bus_class and mdio_bus_type to libphy Heiner Kallweit
2026-03-07 21:34 ` [PATCH net-next 5/5] net: phy: move remaining provider code to mdio_bus_provider.c Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8600cf79-7604-43c1-8cc0-306e58e31153@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox