public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND net-next] mdio: Make use of bus callbacks
@ 2026-01-13 10:26 Uwe Kleine-König
  2026-01-13 14:05 ` Andrew Lunn
  2026-01-17 23:29 ` [RESEND,net-next] " Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-01-13 10:26 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev

Introduce a bus specific probe, remove and shutdown function.

The objective is to get rid of users of struct device_driver callbacks
.probe(), .remove() and .shutdown() to eventually remove these.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
Hello,

it seems I misunderstood when net-next opens, I thought this happens
"automatically" after an -rc1 is tagged and thus delayed the original
submission
(https://lore.kernel.org/netdev/20251216070333.2452582-2-u.kleine-koenig@baylibre.com/)
only until after v6.19-rc1 was tagged. Anyhow, I got a form letter in
reply that net-next was still closed and thus here comes the requested
resend.

I based this patch on top of v6.19-rc1 for my own tracking of similar
patches for other subsystems but it applies fine to net-next/main
(de746f8f53410a0e31d8e5d145745332ee77d321), too.

Best regards
Uwe

 drivers/net/phy/mdio_bus.c    | 56 +++++++++++++++++++++++++++++++++
 drivers/net/phy/mdio_device.c | 58 -----------------------------------
 2 files changed, 56 insertions(+), 58 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index afdf1ad6c0e6..dea67470a7bf 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -1004,11 +1004,67 @@ static const struct attribute_group *mdio_bus_dev_groups[] = {
 	NULL,
 };
 
+/**
+ * mdio_bus_probe - probe an MDIO device
+ * @dev: device to probe
+ *
+ * Description: Take care of setting up the mdio_device structure
+ * and calling the driver to probe the device.
+ *
+ * Return: Zero if successful, negative error code on failure
+ */
+static int mdio_bus_probe(struct device *dev)
+{
+	struct mdio_device *mdiodev = to_mdio_device(dev);
+	struct device_driver *drv = dev->driver;
+	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
+	int err = 0;
+
+	/* Deassert the reset signal */
+	mdio_device_reset(mdiodev, 0);
+
+	if (mdiodrv->probe) {
+		err = mdiodrv->probe(mdiodev);
+		if (err) {
+			/* Assert the reset signal */
+			mdio_device_reset(mdiodev, 1);
+		}
+	}
+
+	return err;
+}
+
+static void mdio_bus_remove(struct device *dev)
+{
+	struct mdio_device *mdiodev = to_mdio_device(dev);
+	struct device_driver *drv = dev->driver;
+	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
+
+	if (mdiodrv->remove)
+		mdiodrv->remove(mdiodev);
+
+	/* Assert the reset signal */
+	mdio_device_reset(mdiodev, 1);
+}
+
+static void mdio_bus_shutdown(struct device *dev)
+{
+	struct mdio_device *mdiodev = to_mdio_device(dev);
+	struct device_driver *drv = dev->driver;
+	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
+
+	if (drv && mdiodrv->shutdown)
+		mdiodrv->shutdown(mdiodev);
+}
+
 const struct bus_type mdio_bus_type = {
 	.name		= "mdio_bus",
 	.dev_groups	= mdio_bus_dev_groups,
 	.match		= mdio_bus_match,
 	.uevent		= mdio_uevent,
+	.probe		= mdio_bus_probe,
+	.remove		= mdio_bus_remove,
+	.shutdown	= mdio_bus_shutdown,
 };
 EXPORT_SYMBOL(mdio_bus_type);
 
diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index 6e90ed42cd98..29172fa8d0df 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -202,61 +202,6 @@ void mdio_device_reset(struct mdio_device *mdiodev, int value)
 }
 EXPORT_SYMBOL(mdio_device_reset);
 
-/**
- * mdio_probe - probe an MDIO device
- * @dev: device to probe
- *
- * Description: Take care of setting up the mdio_device structure
- * and calling the driver to probe the device.
- *
- * Return: Zero if successful, negative error code on failure
- */
-static int mdio_probe(struct device *dev)
-{
-	struct mdio_device *mdiodev = to_mdio_device(dev);
-	struct device_driver *drv = mdiodev->dev.driver;
-	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
-	int err = 0;
-
-	/* Deassert the reset signal */
-	mdio_device_reset(mdiodev, 0);
-
-	if (mdiodrv->probe) {
-		err = mdiodrv->probe(mdiodev);
-		if (err) {
-			/* Assert the reset signal */
-			mdio_device_reset(mdiodev, 1);
-		}
-	}
-
-	return err;
-}
-
-static int mdio_remove(struct device *dev)
-{
-	struct mdio_device *mdiodev = to_mdio_device(dev);
-	struct device_driver *drv = mdiodev->dev.driver;
-	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
-
-	if (mdiodrv->remove)
-		mdiodrv->remove(mdiodev);
-
-	/* Assert the reset signal */
-	mdio_device_reset(mdiodev, 1);
-
-	return 0;
-}
-
-static void mdio_shutdown(struct device *dev)
-{
-	struct mdio_device *mdiodev = to_mdio_device(dev);
-	struct device_driver *drv = mdiodev->dev.driver;
-	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
-
-	if (mdiodrv->shutdown)
-		mdiodrv->shutdown(mdiodev);
-}
-
 /**
  * mdio_driver_register - register an mdio_driver with the MDIO layer
  * @drv: new mdio_driver to register
@@ -271,9 +216,6 @@ int mdio_driver_register(struct mdio_driver *drv)
 	pr_debug("%s: %s\n", __func__, mdiodrv->driver.name);
 
 	mdiodrv->driver.bus = &mdio_bus_type;
-	mdiodrv->driver.probe = mdio_probe;
-	mdiodrv->driver.remove = mdio_remove;
-	mdiodrv->driver.shutdown = mdio_shutdown;
 
 	retval = driver_register(&mdiodrv->driver);
 	if (retval) {

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND net-next] mdio: Make use of bus callbacks
  2026-01-13 10:26 [PATCH RESEND net-next] mdio: Make use of bus callbacks Uwe Kleine-König
@ 2026-01-13 14:05 ` Andrew Lunn
  2026-01-17 23:29 ` [RESEND,net-next] " Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2026-01-13 14:05 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev

> Hello,
> 
> it seems I misunderstood when net-next opens, I thought this happens
> "automatically" after an -rc1

Normally yes, although it is a manual operation, Jakub sends an email
saying it is open. However, this time, there was a poll of
Maintainers, and it was decided to keep it closed until January due to
the holidays and not having Maintainer bandwidth to process patches.

	Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND,net-next] mdio: Make use of bus callbacks
  2026-01-13 10:26 [PATCH RESEND net-next] mdio: Make use of bus callbacks Uwe Kleine-König
  2026-01-13 14:05 ` Andrew Lunn
@ 2026-01-17 23:29 ` Jakub Kicinski
  2026-01-19  9:40   ` Uwe Kleine-König
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2026-01-17 23:29 UTC (permalink / raw)
  To: u.kleine-koenig
  Cc: Jakub Kicinski, netdev, andrew, davem, edumazet, linux,
	hkallweit1, pabeni

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
mdio: Make use of bus callbacks

This patch moves MDIO device probe/remove/shutdown callbacks from the
device_driver level to the bus_type level, with the goal of eventually
removing device_driver callbacks.

> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index afdf1ad6c0e6..dea67470a7bf 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c

[ ... ]

> @@ -1004,11 +1004,67 @@ static const struct attribute_group *mdio_bus_dev_groups[] = {
>  	NULL,
>  };
>
> +/**
> + * mdio_bus_probe - probe an MDIO device
> + * @dev: device to probe
> + *
> + * Description: Take care of setting up the mdio_device structure
> + * and calling the driver to probe the device.
> + *
> + * Return: Zero if successful, negative error code on failure
> + */
> +static int mdio_bus_probe(struct device *dev)
> +{
> +	struct mdio_device *mdiodev = to_mdio_device(dev);
> +	struct device_driver *drv = dev->driver;
> +	struct mdio_driver *mdiodrv = to_mdio_driver(drv);

[ ... ]

>  const struct bus_type mdio_bus_type = {
>  	.name		= "mdio_bus",
>  	.dev_groups	= mdio_bus_dev_groups,
>  	.match		= mdio_bus_match,
>  	.uevent		= mdio_uevent,
> +	.probe		= mdio_bus_probe,
> +	.remove		= mdio_bus_remove,
> +	.shutdown	= mdio_bus_shutdown,
>  };

Does adding these bus-level callbacks break PHY device probing?

PHY drivers register via phy_driver_register() which sets:

    new_driver->mdiodrv.driver.probe = phy_probe;
    new_driver->mdiodrv.driver.remove = phy_remove;

The driver core in call_driver_probe() prioritizes bus callbacks over driver
callbacks:

    if (dev->bus->probe)
        ret = dev->bus->probe(dev);
    else if (drv->probe)
        ret = drv->probe(dev);

With mdio_bus_type.probe now set, phy_probe() will never be called for PHY
devices. The same applies to phy_remove() being bypassed by mdio_bus_remove().

phy_probe() performs essential initialization including setting phydev->drv,
reading PHY abilities, configuring EEE, and setting up the state machine.
Without this, PHY devices would fail to initialize properly.

Was there a plan to update phy_driver_register() as part of this change, or
is a separate patch needed to handle PHY drivers?
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND,net-next] mdio: Make use of bus callbacks
  2026-01-17 23:29 ` [RESEND,net-next] " Jakub Kicinski
@ 2026-01-19  9:40   ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-01-19  9:40 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, andrew, davem, edumazet, linux, hkallweit1, pabeni

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

Hello Jakub,

On Sat, Jan 17, 2026 at 03:29:32PM -0800, Jakub Kicinski wrote:
> Does adding these bus-level callbacks break PHY device probing?
> 
> PHY drivers register via phy_driver_register() which sets:
> 
>     new_driver->mdiodrv.driver.probe = phy_probe;
>     new_driver->mdiodrv.driver.remove = phy_remove;
> 
> The driver core in call_driver_probe() prioritizes bus callbacks over driver
> callbacks:
> 
>     if (dev->bus->probe)
>         ret = dev->bus->probe(dev);
>     else if (drv->probe)
>         ret = drv->probe(dev);
> 
> With mdio_bus_type.probe now set, phy_probe() will never be called for PHY
> devices. The same applies to phy_remove() being bypassed by mdio_bus_remove().
> 
> phy_probe() performs essential initialization including setting phydev->drv,
> reading PHY abilities, configuring EEE, and setting up the state machine.
> Without this, PHY devices would fail to initialize properly.
> 
> Was there a plan to update phy_driver_register() as part of this change, or
> is a separate patch needed to handle PHY drivers?

I think the concern is valid. I'll look into this and send an update
when I convinced myself that I'm not breaking anything.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-19  9:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 10:26 [PATCH RESEND net-next] mdio: Make use of bus callbacks Uwe Kleine-König
2026-01-13 14:05 ` Andrew Lunn
2026-01-17 23:29 ` [RESEND,net-next] " Jakub Kicinski
2026-01-19  9:40   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox