All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib
@ 2025-09-13 21:05 Heiner Kallweit
  2025-09-13 21:07 ` [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info Heiner Kallweit
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-13 21:05 UTC (permalink / raw)
  To: Russell King - ARM Linux, Andrew Lunn, Andrew Lunn, Paolo Abeni,
	Jakub Kicinski, Eric Dumazet, David Miller, Vladimir Oltean
  Cc: netdev@vger.kernel.org

Since its introduction in 2017 mdio_board_info has had only two users:
- dsa_loop (still existing)
- arm orion, added in 2017 and removed with fd68572b57f2 ("ARM: orion5x:
  remove dsa_chip_data references")

So let's remove usage of mdio_board_info from dsa_loop, then support
for mdio_board_info can be dropped from phylib.

Heiner Kallweit (2):
  net: dsa: dsa_loop: remove usage of mdio_board_info
  net: phy: remove mdio_board_info support from phylib

 drivers/net/dsa/Makefile            |  3 --
 drivers/net/dsa/dsa_loop.c          | 63 +++++++++++++++++++++--
 drivers/net/dsa/dsa_loop.h          | 20 --------
 drivers/net/dsa/dsa_loop_bdinfo.c   | 36 -------------
 drivers/net/phy/Makefile            |  2 +-
 drivers/net/phy/mdio-boardinfo.c    | 79 -----------------------------
 drivers/net/phy/mdio-boardinfo.h    | 18 -------
 drivers/net/phy/mdio_bus_provider.c | 33 ------------
 include/linux/phy.h                 | 10 ----
 9 files changed, 61 insertions(+), 203 deletions(-)
 delete mode 100644 drivers/net/dsa/dsa_loop.h
 delete mode 100644 drivers/net/dsa/dsa_loop_bdinfo.c
 delete mode 100644 drivers/net/phy/mdio-boardinfo.c
 delete mode 100644 drivers/net/phy/mdio-boardinfo.h

-- 
2.51.0


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

* [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info
  2025-09-13 21:05 [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
@ 2025-09-13 21:07 ` Heiner Kallweit
  2025-09-17  7:40   ` Vladimir Oltean
  2025-09-13 21:08 ` [PATCH net-next 2/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
  2025-09-17 22:40 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-13 21:07 UTC (permalink / raw)
  To: Russell King - ARM Linux, Andrew Lunn, Andrew Lunn, Paolo Abeni,
	Jakub Kicinski, Eric Dumazet, David Miller, Vladimir Oltean
  Cc: netdev@vger.kernel.org

dsa_loop is the last remaining user of mdio_board_info. Let's remove
using mdio_board_info, so that support for it can be dropped from
phylib.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/dsa/Makefile          |  3 --
 drivers/net/dsa/dsa_loop.c        | 63 +++++++++++++++++++++++++++++--
 drivers/net/dsa/dsa_loop.h        | 20 ----------
 drivers/net/dsa/dsa_loop_bdinfo.c | 36 ------------------
 4 files changed, 60 insertions(+), 62 deletions(-)
 delete mode 100644 drivers/net/dsa/dsa_loop.h
 delete mode 100644 drivers/net/dsa/dsa_loop_bdinfo.c

diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile
index c0a534fe6..0f8ff4a1a 100644
--- a/drivers/net/dsa/Makefile
+++ b/drivers/net/dsa/Makefile
@@ -2,9 +2,6 @@
 obj-$(CONFIG_NET_DSA_BCM_SF2)	+= bcm-sf2.o
 bcm-sf2-objs			:= bcm_sf2.o bcm_sf2_cfp.o
 obj-$(CONFIG_NET_DSA_LOOP)	+= dsa_loop.o
-ifdef CONFIG_NET_DSA_LOOP
-obj-$(CONFIG_FIXED_PHY)		+= dsa_loop_bdinfo.o
-endif
 obj-$(CONFIG_NET_DSA_KS8995) 	+= ks8995.o
 obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530.o
 obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 8112515d5..720738807 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -17,7 +17,19 @@
 #include <linux/dsa/loop.h>
 #include <net/dsa.h>
 
-#include "dsa_loop.h"
+#define DSA_LOOP_NUM_PORTS	6
+#define DSA_LOOP_CPU_PORT	(DSA_LOOP_NUM_PORTS - 1)
+#define NUM_FIXED_PHYS		(DSA_LOOP_NUM_PORTS - 2)
+
+struct dsa_loop_pdata {
+	/* Must be first, such that dsa_register_switch() can access this
+	 * without gory pointer manipulations
+	 */
+	struct dsa_chip_data cd;
+	const char *name;
+	unsigned int enabled_ports;
+	const char *netdev;
+};
 
 static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
 	[DSA_LOOP_PHY_READ_OK]	= { "phy_read_ok", },
@@ -27,6 +39,7 @@ static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
 };
 
 static struct phy_device *phydevs[PHY_MAX_ADDR];
+static struct mdio_device *switch_mdiodev;
 
 enum dsa_loop_devlink_resource_id {
 	DSA_LOOP_DEVLINK_PARAM_ID_VTU,
@@ -392,6 +405,42 @@ static void dsa_loop_phydevs_unregister(void)
 	}
 }
 
+static int __init dsa_loop_create_switch_mdiodev(void)
+{
+	static struct dsa_loop_pdata dsa_loop_pdata = {
+		.cd = {
+			.port_names[0] = "lan1",
+			.port_names[1] = "lan2",
+			.port_names[2] = "lan3",
+			.port_names[3] = "lan4",
+			.port_names[DSA_LOOP_CPU_PORT] = "cpu",
+		},
+		.name = "DSA mockup driver",
+		.enabled_ports = 0x1f,
+		.netdev = "eth0",
+	};
+	struct mii_bus *bus;
+	int ret = -ENODEV;
+
+	bus = mdio_find_bus("fixed-0");
+	if (WARN_ON(!bus))
+		return ret;
+
+	switch_mdiodev = mdio_device_create(bus, 31);
+	if (IS_ERR(switch_mdiodev))
+		goto out;
+
+	strscpy(switch_mdiodev->modalias, "dsa-loop");
+	switch_mdiodev->dev.platform_data = &dsa_loop_pdata;
+
+	ret = mdio_device_register(switch_mdiodev);
+	if (ret)
+		mdio_device_free(switch_mdiodev);
+out:
+	put_device(&bus->dev);
+	return ret;
+}
+
 static int __init dsa_loop_init(void)
 {
 	struct fixed_phy_status status = {
@@ -402,12 +451,19 @@ static int __init dsa_loop_init(void)
 	unsigned int i;
 	int ret;
 
+	ret = dsa_loop_create_switch_mdiodev();
+	if (ret)
+		return ret;
+
 	for (i = 0; i < NUM_FIXED_PHYS; i++)
 		phydevs[i] = fixed_phy_register(&status, NULL);
 
 	ret = mdio_driver_register(&dsa_loop_drv);
-	if (ret)
+	if (ret) {
 		dsa_loop_phydevs_unregister();
+		mdio_device_remove(switch_mdiodev);
+		mdio_device_free(switch_mdiodev);
+	}
 
 	return ret;
 }
@@ -417,10 +473,11 @@ static void __exit dsa_loop_exit(void)
 {
 	mdio_driver_unregister(&dsa_loop_drv);
 	dsa_loop_phydevs_unregister();
+	mdio_device_remove(switch_mdiodev);
+	mdio_device_free(switch_mdiodev);
 }
 module_exit(dsa_loop_exit);
 
-MODULE_SOFTDEP("pre: dsa_loop_bdinfo");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Florian Fainelli");
 MODULE_DESCRIPTION("DSA loopback driver");
diff --git a/drivers/net/dsa/dsa_loop.h b/drivers/net/dsa/dsa_loop.h
deleted file mode 100644
index 93e5c15d0..000000000
--- a/drivers/net/dsa/dsa_loop.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __DSA_LOOP_H
-#define __DSA_LOOP_H
-
-struct dsa_chip_data;
-
-struct dsa_loop_pdata {
-	/* Must be first, such that dsa_register_switch() can access this
-	 * without gory pointer manipulations
-	 */
-	struct dsa_chip_data cd;
-	const char *name;
-	unsigned int enabled_ports;
-	const char *netdev;
-};
-
-#define DSA_LOOP_NUM_PORTS	6
-#define DSA_LOOP_CPU_PORT	(DSA_LOOP_NUM_PORTS - 1)
-
-#endif /* __DSA_LOOP_H */
diff --git a/drivers/net/dsa/dsa_loop_bdinfo.c b/drivers/net/dsa/dsa_loop_bdinfo.c
deleted file mode 100644
index 14ca42491..000000000
--- a/drivers/net/dsa/dsa_loop_bdinfo.c
+++ /dev/null
@@ -1,36 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/phy.h>
-#include <net/dsa.h>
-
-#include "dsa_loop.h"
-
-static struct dsa_loop_pdata dsa_loop_pdata = {
-	.cd = {
-		.port_names[0] = "lan1",
-		.port_names[1] = "lan2",
-		.port_names[2] = "lan3",
-		.port_names[3] = "lan4",
-		.port_names[DSA_LOOP_CPU_PORT] = "cpu",
-	},
-	.name = "DSA mockup driver",
-	.enabled_ports = 0x1f,
-	.netdev = "eth0",
-};
-
-static const struct mdio_board_info bdinfo = {
-	.bus_id	= "fixed-0",
-	.modalias = "dsa-loop",
-	.mdio_addr = 31,
-	.platform_data = &dsa_loop_pdata,
-};
-
-static int __init dsa_loop_bdinfo_init(void)
-{
-	return mdiobus_register_board_info(&bdinfo, 1);
-}
-arch_initcall(dsa_loop_bdinfo_init)
-
-MODULE_DESCRIPTION("DSA mock-up switch driver");
-MODULE_LICENSE("GPL");
-- 
2.51.0



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

* [PATCH net-next 2/2] net: phy: remove mdio_board_info support from phylib
  2025-09-13 21:05 [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
  2025-09-13 21:07 ` [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info Heiner Kallweit
@ 2025-09-13 21:08 ` Heiner Kallweit
  2025-09-17 22:40 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-13 21:08 UTC (permalink / raw)
  To: Russell King - ARM Linux, Andrew Lunn, Andrew Lunn, Paolo Abeni,
	Jakub Kicinski, Eric Dumazet, David Miller, Vladimir Oltean
  Cc: netdev@vger.kernel.org

After having removed mdio_board_info usage from dsa_loop, there's no
user left. So let's drop support for it from phylib.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/Makefile            |  2 +-
 drivers/net/phy/mdio-boardinfo.c    | 79 -----------------------------
 drivers/net/phy/mdio-boardinfo.h    | 18 -------
 drivers/net/phy/mdio_bus_provider.c | 33 ------------
 include/linux/phy.h                 | 10 ----
 5 files changed, 1 insertion(+), 141 deletions(-)
 delete mode 100644 drivers/net/phy/mdio-boardinfo.c
 delete mode 100644 drivers/net/phy/mdio-boardinfo.h

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 402a33d55..76e0db40f 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -8,7 +8,7 @@ mdio-bus-y			+= mdio_bus.o mdio_device.o
 
 ifdef CONFIG_PHYLIB
 # built-in whenever PHYLIB is built-in or module
-obj-y				+= stubs.o mdio-boardinfo.o
+obj-y				+= stubs.o
 endif
 
 libphy-$(CONFIG_SWPHY)		+= swphy.o
diff --git a/drivers/net/phy/mdio-boardinfo.c b/drivers/net/phy/mdio-boardinfo.c
deleted file mode 100644
index d3184e8f1..000000000
--- a/drivers/net/phy/mdio-boardinfo.c
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * mdio-boardinfo - Collect pre-declarations for MDIO devices
- */
-
-#include <linux/export.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/mutex.h>
-#include <linux/phy.h>
-#include <linux/slab.h>
-
-#include "mdio-boardinfo.h"
-
-static LIST_HEAD(mdio_board_list);
-static DEFINE_MUTEX(mdio_board_lock);
-
-struct mdio_board_entry {
-	struct list_head	list;
-	struct mdio_board_info	board_info;
-};
-
-/**
- * mdiobus_setup_mdiodev_from_board_info - create and setup MDIO devices
- * from pre-collected board specific MDIO information
- * @bus: Bus the board_info belongs to
- * @cb: Callback to create device on bus
- * Context: can sleep
- */
-void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
-					   int (*cb)
-					   (struct mii_bus *bus,
-					    struct mdio_board_info *bi))
-{
-	struct mdio_board_entry *be, *tmp;
-
-	mutex_lock(&mdio_board_lock);
-	list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
-		struct mdio_board_info *bi = &be->board_info;
-
-		if (strcmp(bus->id, bi->bus_id))
-			continue;
-
-		mutex_unlock(&mdio_board_lock);
-		cb(bus, bi);
-		mutex_lock(&mdio_board_lock);
-	}
-	mutex_unlock(&mdio_board_lock);
-}
-EXPORT_SYMBOL(mdiobus_setup_mdiodev_from_board_info);
-
-/**
- * mdiobus_register_board_info - register MDIO devices for a given board
- * @info: array of devices descriptors
- * @n: number of descriptors provided
- * Context: can sleep
- *
- * The board info passed can be marked with __initdata but be pointers
- * such as platform_data etc. are copied as-is
- */
-int mdiobus_register_board_info(const struct mdio_board_info *info,
-				unsigned int n)
-{
-	struct mdio_board_entry *be;
-
-	be = kcalloc(n, sizeof(*be), GFP_KERNEL);
-	if (!be)
-		return -ENOMEM;
-
-	for (int i = 0; i < n; i++, be++) {
-		be->board_info = info[i];
-		mutex_lock(&mdio_board_lock);
-		list_add_tail(&be->list, &mdio_board_list);
-		mutex_unlock(&mdio_board_lock);
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(mdiobus_register_board_info);
diff --git a/drivers/net/phy/mdio-boardinfo.h b/drivers/net/phy/mdio-boardinfo.h
deleted file mode 100644
index 0878b7787..000000000
--- a/drivers/net/phy/mdio-boardinfo.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * mdio-boardinfo.h - board info interface internal to the mdio_bus
- * component
- */
-
-#ifndef __MDIO_BOARD_INFO_H
-#define __MDIO_BOARD_INFO_H
-
-struct mii_bus;
-struct mdio_board_info;
-
-void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
-					   int (*cb)
-					   (struct mii_bus *bus,
-					    struct mdio_board_info *bi));
-
-#endif /* __MDIO_BOARD_INFO_H */
diff --git a/drivers/net/phy/mdio_bus_provider.c b/drivers/net/phy/mdio_bus_provider.c
index f43973e73..a2391d4b7 100644
--- a/drivers/net/phy/mdio_bus_provider.c
+++ b/drivers/net/phy/mdio_bus_provider.c
@@ -29,8 +29,6 @@
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
 
-#include "mdio-boardinfo.h"
-
 /**
  * mdiobus_alloc_size - allocate a mii_bus structure
  * @size: extra amount of memory to allocate for private storage.
@@ -132,35 +130,6 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus,
 }
 #endif
 
-/**
- * mdiobus_create_device - create a full MDIO device given
- * a mdio_board_info structure
- * @bus: MDIO bus to create the devices on
- * @bi: mdio_board_info structure describing the devices
- *
- * Returns 0 on success or < 0 on error.
- */
-static int mdiobus_create_device(struct mii_bus *bus,
-				 struct mdio_board_info *bi)
-{
-	struct mdio_device *mdiodev;
-	int ret = 0;
-
-	mdiodev = mdio_device_create(bus, bi->mdio_addr);
-	if (IS_ERR(mdiodev))
-		return -ENODEV;
-
-	strscpy(mdiodev->modalias, bi->modalias,
-		sizeof(mdiodev->modalias));
-	mdiodev->dev.platform_data = (void *)bi->platform_data;
-
-	ret = mdio_device_register(mdiodev);
-	if (ret)
-		mdio_device_free(mdiodev);
-
-	return ret;
-}
-
 static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45)
 {
 	struct phy_device *phydev = ERR_PTR(-ENODEV);
@@ -404,8 +373,6 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
 			goto error;
 	}
 
-	mdiobus_setup_mdiodev_from_board_info(bus, mdiobus_create_device);
-
 	bus->state = MDIOBUS_REGISTERED;
 	dev_dbg(&bus->dev, "probed\n");
 	return 0;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 04553419a..249aee317 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2116,16 +2116,6 @@ int __phy_hwtstamp_set(struct phy_device *phydev,
 extern const struct bus_type mdio_bus_type;
 extern const struct class mdio_bus_class;
 
-struct mdio_board_info {
-	const char	*bus_id;
-	char		modalias[MDIO_NAME_SIZE];
-	int		mdio_addr;
-	const void	*platform_data;
-};
-
-int mdiobus_register_board_info(const struct mdio_board_info *info,
-				unsigned int n);
-
 /**
  * phy_module_driver() - Helper macro for registering PHY drivers
  * @__phy_drivers: array of PHY drivers to register
-- 
2.51.0



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

* Re: [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info
  2025-09-13 21:07 ` [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info Heiner Kallweit
@ 2025-09-17  7:40   ` Vladimir Oltean
  0 siblings, 0 replies; 5+ messages in thread
From: Vladimir Oltean @ 2025-09-17  7:40 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Russell King - ARM Linux, Andrew Lunn, Andrew Lunn, Paolo Abeni,
	Jakub Kicinski, Eric Dumazet, David Miller,
	netdev@vger.kernel.org

On Sat, Sep 13, 2025 at 11:07:08PM +0200, Heiner Kallweit wrote:
> dsa_loop is the last remaining user of mdio_board_info. Let's remove
> using mdio_board_info, so that support for it can be dropped from
> phylib.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---

Thanks for the conversion! It looks really good.

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Tested-by: Vladimir Oltean <olteanv@gmail.com>

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

* Re: [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib
  2025-09-13 21:05 [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
  2025-09-13 21:07 ` [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info Heiner Kallweit
  2025-09-13 21:08 ` [PATCH net-next 2/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
@ 2025-09-17 22:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-17 22:40 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: linux, andrew, andrew+netdev, pabeni, kuba, edumazet, davem,
	olteanv, netdev

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 13 Sep 2025 23:05:15 +0200 you wrote:
> Since its introduction in 2017 mdio_board_info has had only two users:
> - dsa_loop (still existing)
> - arm orion, added in 2017 and removed with fd68572b57f2 ("ARM: orion5x:
>   remove dsa_chip_data references")
> 
> So let's remove usage of mdio_board_info from dsa_loop, then support
> for mdio_board_info can be dropped from phylib.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: dsa: dsa_loop: remove usage of mdio_board_info
    https://git.kernel.org/netdev/net-next/c/41357bc7b94b
  - [net-next,2/2] net: phy: remove mdio_board_info support from phylib
    https://git.kernel.org/netdev/net-next/c/b67a8631a4a8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-09-17 22:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-13 21:05 [PATCH net-next 0/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
2025-09-13 21:07 ` [PATCH net-next 1/2] net: dsa: dsa_loop: remove usage of mdio_board_info Heiner Kallweit
2025-09-17  7:40   ` Vladimir Oltean
2025-09-13 21:08 ` [PATCH net-next 2/2] net: phy: remove mdio_board_info support from phylib Heiner Kallweit
2025-09-17 22:40 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.