Commit 6b957c0a authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-phy-remove-mdio_board_info-support-from-phylib'

Heiner Kallweit says:

====================
net: phy: remove mdio_board_info support from phylib

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 fd68572b ("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.
====================

Link: https://patch.msgid.link/4ccf7476-0744-4f6b-aafc-7ba84d15a432@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2479cba2 b67a8631
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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
+60 −3
Original line number Diff line number Diff line
@@ -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");

drivers/net/dsa/dsa_loop.h

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
/* 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 */

drivers/net/dsa/dsa_loop_bdinfo.c

deleted100644 → 0
+0 −36
Original line number Diff line number Diff line
// 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");
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading