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 fd68572b57 ("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: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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 */
|
||||
@@ -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");
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
|
||||
@@ -2129,16 +2129,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
|
||||
|
||||
Reference in New Issue
Block a user