Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 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.
====================

Link: https://patch.msgid.link/4ccf7476-0744-4f6b-aafc-7ba84d15a432@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+61 -203
-3
drivers/net/dsa/Makefile
··· 2 2 obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm-sf2.o 3 3 bcm-sf2-objs := bcm_sf2.o bcm_sf2_cfp.o 4 4 obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o 5 - ifdef CONFIG_NET_DSA_LOOP 6 - obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdinfo.o 7 - endif 8 5 obj-$(CONFIG_NET_DSA_KS8995) += ks8995.o 9 6 obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o 10 7 obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
+60 -3
drivers/net/dsa/dsa_loop.c
··· 17 17 #include <linux/dsa/loop.h> 18 18 #include <net/dsa.h> 19 19 20 - #include "dsa_loop.h" 20 + #define DSA_LOOP_NUM_PORTS 6 21 + #define DSA_LOOP_CPU_PORT (DSA_LOOP_NUM_PORTS - 1) 22 + #define NUM_FIXED_PHYS (DSA_LOOP_NUM_PORTS - 2) 23 + 24 + struct dsa_loop_pdata { 25 + /* Must be first, such that dsa_register_switch() can access this 26 + * without gory pointer manipulations 27 + */ 28 + struct dsa_chip_data cd; 29 + const char *name; 30 + unsigned int enabled_ports; 31 + const char *netdev; 32 + }; 21 33 22 34 static struct dsa_loop_mib_entry dsa_loop_mibs[] = { 23 35 [DSA_LOOP_PHY_READ_OK] = { "phy_read_ok", }, ··· 39 27 }; 40 28 41 29 static struct phy_device *phydevs[PHY_MAX_ADDR]; 30 + static struct mdio_device *switch_mdiodev; 42 31 43 32 enum dsa_loop_devlink_resource_id { 44 33 DSA_LOOP_DEVLINK_PARAM_ID_VTU, ··· 405 392 } 406 393 } 407 394 395 + static int __init dsa_loop_create_switch_mdiodev(void) 396 + { 397 + static struct dsa_loop_pdata dsa_loop_pdata = { 398 + .cd = { 399 + .port_names[0] = "lan1", 400 + .port_names[1] = "lan2", 401 + .port_names[2] = "lan3", 402 + .port_names[3] = "lan4", 403 + .port_names[DSA_LOOP_CPU_PORT] = "cpu", 404 + }, 405 + .name = "DSA mockup driver", 406 + .enabled_ports = 0x1f, 407 + .netdev = "eth0", 408 + }; 409 + struct mii_bus *bus; 410 + int ret = -ENODEV; 411 + 412 + bus = mdio_find_bus("fixed-0"); 413 + if (WARN_ON(!bus)) 414 + return ret; 415 + 416 + switch_mdiodev = mdio_device_create(bus, 31); 417 + if (IS_ERR(switch_mdiodev)) 418 + goto out; 419 + 420 + strscpy(switch_mdiodev->modalias, "dsa-loop"); 421 + switch_mdiodev->dev.platform_data = &dsa_loop_pdata; 422 + 423 + ret = mdio_device_register(switch_mdiodev); 424 + if (ret) 425 + mdio_device_free(switch_mdiodev); 426 + out: 427 + put_device(&bus->dev); 428 + return ret; 429 + } 430 + 408 431 static int __init dsa_loop_init(void) 409 432 { 410 433 struct fixed_phy_status status = { ··· 451 402 unsigned int i; 452 403 int ret; 453 404 405 + ret = dsa_loop_create_switch_mdiodev(); 406 + if (ret) 407 + return ret; 408 + 454 409 for (i = 0; i < NUM_FIXED_PHYS; i++) 455 410 phydevs[i] = fixed_phy_register(&status, NULL); 456 411 457 412 ret = mdio_driver_register(&dsa_loop_drv); 458 - if (ret) 413 + if (ret) { 459 414 dsa_loop_phydevs_unregister(); 415 + mdio_device_remove(switch_mdiodev); 416 + mdio_device_free(switch_mdiodev); 417 + } 460 418 461 419 return ret; 462 420 } ··· 473 417 { 474 418 mdio_driver_unregister(&dsa_loop_drv); 475 419 dsa_loop_phydevs_unregister(); 420 + mdio_device_remove(switch_mdiodev); 421 + mdio_device_free(switch_mdiodev); 476 422 } 477 423 module_exit(dsa_loop_exit); 478 424 479 - MODULE_SOFTDEP("pre: dsa_loop_bdinfo"); 480 425 MODULE_LICENSE("GPL"); 481 426 MODULE_AUTHOR("Florian Fainelli"); 482 427 MODULE_DESCRIPTION("DSA loopback driver");
-20
drivers/net/dsa/dsa_loop.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __DSA_LOOP_H 3 - #define __DSA_LOOP_H 4 - 5 - struct dsa_chip_data; 6 - 7 - struct dsa_loop_pdata { 8 - /* Must be first, such that dsa_register_switch() can access this 9 - * without gory pointer manipulations 10 - */ 11 - struct dsa_chip_data cd; 12 - const char *name; 13 - unsigned int enabled_ports; 14 - const char *netdev; 15 - }; 16 - 17 - #define DSA_LOOP_NUM_PORTS 6 18 - #define DSA_LOOP_CPU_PORT (DSA_LOOP_NUM_PORTS - 1) 19 - 20 - #endif /* __DSA_LOOP_H */
-36
drivers/net/dsa/dsa_loop_bdinfo.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - #include <linux/kernel.h> 3 - #include <linux/init.h> 4 - #include <linux/phy.h> 5 - #include <net/dsa.h> 6 - 7 - #include "dsa_loop.h" 8 - 9 - static struct dsa_loop_pdata dsa_loop_pdata = { 10 - .cd = { 11 - .port_names[0] = "lan1", 12 - .port_names[1] = "lan2", 13 - .port_names[2] = "lan3", 14 - .port_names[3] = "lan4", 15 - .port_names[DSA_LOOP_CPU_PORT] = "cpu", 16 - }, 17 - .name = "DSA mockup driver", 18 - .enabled_ports = 0x1f, 19 - .netdev = "eth0", 20 - }; 21 - 22 - static const struct mdio_board_info bdinfo = { 23 - .bus_id = "fixed-0", 24 - .modalias = "dsa-loop", 25 - .mdio_addr = 31, 26 - .platform_data = &dsa_loop_pdata, 27 - }; 28 - 29 - static int __init dsa_loop_bdinfo_init(void) 30 - { 31 - return mdiobus_register_board_info(&bdinfo, 1); 32 - } 33 - arch_initcall(dsa_loop_bdinfo_init) 34 - 35 - MODULE_DESCRIPTION("DSA mock-up switch driver"); 36 - MODULE_LICENSE("GPL");
+1 -1
drivers/net/phy/Makefile
··· 8 8 9 9 ifdef CONFIG_PHYLIB 10 10 # built-in whenever PHYLIB is built-in or module 11 - obj-y += stubs.o mdio-boardinfo.o 11 + obj-y += stubs.o 12 12 endif 13 13 14 14 libphy-$(CONFIG_SWPHY) += swphy.o
-79
drivers/net/phy/mdio-boardinfo.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* 3 - * mdio-boardinfo - Collect pre-declarations for MDIO devices 4 - */ 5 - 6 - #include <linux/export.h> 7 - #include <linux/kernel.h> 8 - #include <linux/list.h> 9 - #include <linux/mutex.h> 10 - #include <linux/phy.h> 11 - #include <linux/slab.h> 12 - 13 - #include "mdio-boardinfo.h" 14 - 15 - static LIST_HEAD(mdio_board_list); 16 - static DEFINE_MUTEX(mdio_board_lock); 17 - 18 - struct mdio_board_entry { 19 - struct list_head list; 20 - struct mdio_board_info board_info; 21 - }; 22 - 23 - /** 24 - * mdiobus_setup_mdiodev_from_board_info - create and setup MDIO devices 25 - * from pre-collected board specific MDIO information 26 - * @bus: Bus the board_info belongs to 27 - * @cb: Callback to create device on bus 28 - * Context: can sleep 29 - */ 30 - void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus, 31 - int (*cb) 32 - (struct mii_bus *bus, 33 - struct mdio_board_info *bi)) 34 - { 35 - struct mdio_board_entry *be, *tmp; 36 - 37 - mutex_lock(&mdio_board_lock); 38 - list_for_each_entry_safe(be, tmp, &mdio_board_list, list) { 39 - struct mdio_board_info *bi = &be->board_info; 40 - 41 - if (strcmp(bus->id, bi->bus_id)) 42 - continue; 43 - 44 - mutex_unlock(&mdio_board_lock); 45 - cb(bus, bi); 46 - mutex_lock(&mdio_board_lock); 47 - } 48 - mutex_unlock(&mdio_board_lock); 49 - } 50 - EXPORT_SYMBOL(mdiobus_setup_mdiodev_from_board_info); 51 - 52 - /** 53 - * mdiobus_register_board_info - register MDIO devices for a given board 54 - * @info: array of devices descriptors 55 - * @n: number of descriptors provided 56 - * Context: can sleep 57 - * 58 - * The board info passed can be marked with __initdata but be pointers 59 - * such as platform_data etc. are copied as-is 60 - */ 61 - int mdiobus_register_board_info(const struct mdio_board_info *info, 62 - unsigned int n) 63 - { 64 - struct mdio_board_entry *be; 65 - 66 - be = kcalloc(n, sizeof(*be), GFP_KERNEL); 67 - if (!be) 68 - return -ENOMEM; 69 - 70 - for (int i = 0; i < n; i++, be++) { 71 - be->board_info = info[i]; 72 - mutex_lock(&mdio_board_lock); 73 - list_add_tail(&be->list, &mdio_board_list); 74 - mutex_unlock(&mdio_board_lock); 75 - } 76 - 77 - return 0; 78 - } 79 - EXPORT_SYMBOL(mdiobus_register_board_info);
-18
drivers/net/phy/mdio-boardinfo.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * mdio-boardinfo.h - board info interface internal to the mdio_bus 4 - * component 5 - */ 6 - 7 - #ifndef __MDIO_BOARD_INFO_H 8 - #define __MDIO_BOARD_INFO_H 9 - 10 - struct mii_bus; 11 - struct mdio_board_info; 12 - 13 - void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus, 14 - int (*cb) 15 - (struct mii_bus *bus, 16 - struct mdio_board_info *bi)); 17 - 18 - #endif /* __MDIO_BOARD_INFO_H */
-33
drivers/net/phy/mdio_bus_provider.c
··· 29 29 #include <linux/uaccess.h> 30 30 #include <linux/unistd.h> 31 31 32 - #include "mdio-boardinfo.h" 33 - 34 32 /** 35 33 * mdiobus_alloc_size - allocate a mii_bus structure 36 34 * @size: extra amount of memory to allocate for private storage. ··· 129 131 of_mdiobus_find_phy(dev, mdiodev, bus->dev.of_node); 130 132 } 131 133 #endif 132 - 133 - /** 134 - * mdiobus_create_device - create a full MDIO device given 135 - * a mdio_board_info structure 136 - * @bus: MDIO bus to create the devices on 137 - * @bi: mdio_board_info structure describing the devices 138 - * 139 - * Returns 0 on success or < 0 on error. 140 - */ 141 - static int mdiobus_create_device(struct mii_bus *bus, 142 - struct mdio_board_info *bi) 143 - { 144 - struct mdio_device *mdiodev; 145 - int ret = 0; 146 - 147 - mdiodev = mdio_device_create(bus, bi->mdio_addr); 148 - if (IS_ERR(mdiodev)) 149 - return -ENODEV; 150 - 151 - strscpy(mdiodev->modalias, bi->modalias, 152 - sizeof(mdiodev->modalias)); 153 - mdiodev->dev.platform_data = (void *)bi->platform_data; 154 - 155 - ret = mdio_device_register(mdiodev); 156 - if (ret) 157 - mdio_device_free(mdiodev); 158 - 159 - return ret; 160 - } 161 134 162 135 static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45) 163 136 { ··· 372 403 if (err) 373 404 goto error; 374 405 } 375 - 376 - mdiobus_setup_mdiodev_from_board_info(bus, mdiobus_create_device); 377 406 378 407 bus->state = MDIOBUS_REGISTERED; 379 408 dev_dbg(&bus->dev, "probed\n");
-10
include/linux/phy.h
··· 2129 2129 extern const struct bus_type mdio_bus_type; 2130 2130 extern const struct class mdio_bus_class; 2131 2131 2132 - struct mdio_board_info { 2133 - const char *bus_id; 2134 - char modalias[MDIO_NAME_SIZE]; 2135 - int mdio_addr; 2136 - const void *platform_data; 2137 - }; 2138 - 2139 - int mdiobus_register_board_info(const struct mdio_board_info *info, 2140 - unsigned int n); 2141 - 2142 2132 /** 2143 2133 * phy_module_driver() - Helper macro for registering PHY drivers 2144 2134 * @__phy_drivers: array of PHY drivers to register