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

net: phy: make mdio_device.c part of libphy

This patch
- makes mdio_device.c part of libphy
- makes mdio_device_(un)register_reset() static
- moves mdiobus_(un)register_device() from mdio_bus.c to mdio_device.c,
stops exporting both functions and makes them private to phylib

This further decouples the MDIO consumer functionality from libphy.

Note: This makes MDIO driver registration part of phylib, therefore
adjust Kconfig dependencies where needed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/c6dbf9b3-3ca0-434b-ad3a-71fe602ab809@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
6df14596 2d7bebc9

+46 -58
+1 -1
drivers/clk/qcom/Kconfig
··· 392 392 393 393 config IPQ_NSSCC_QCA8K 394 394 tristate "QCA8K(QCA8386 or QCA8084) NSS Clock Controller" 395 - depends on MDIO_BUS 395 + depends on PHYLIB 396 396 help 397 397 Support for NSS(Network SubSystem) clock controller on 398 398 qca8386/qca8084 chip.
+3 -3
drivers/net/phy/Makefile
··· 3 3 4 4 libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \ 5 5 linkmode.o phy_link_topology.o \ 6 - phy_caps.o mdio_bus_provider.o phy_port.o 7 - mdio-bus-y += mdio_bus.o mdio_device.o 6 + phy_caps.o mdio_bus_provider.o phy_port.o \ 7 + mdio_device.o 8 8 9 9 ifdef CONFIG_PHYLIB 10 10 # built-in whenever PHYLIB is built-in or module ··· 15 15 libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o 16 16 libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) += open_alliance_helpers.o 17 17 18 - obj-$(CONFIG_MDIO_BUS) += mdio-bus.o 18 + obj-$(CONFIG_MDIO_BUS) += mdio_bus.o 19 19 obj-$(CONFIG_PHYLINK) += phylink.o 20 20 obj-$(CONFIG_PHYLIB) += libphy.o 21 21 obj-$(CONFIG_PHYLIB) += mdio_devres.o
-11
drivers/net/phy/mdio-private.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - #ifndef __MDIO_PRIVATE_H 3 - #define __MDIO_PRIVATE_H 4 - 5 - /* MDIO internal helpers 6 - */ 7 - 8 - int mdio_device_register_reset(struct mdio_device *mdiodev); 9 - void mdio_device_unregister_reset(struct mdio_device *mdiodev); 10 - 11 - #endif /* __MDIO_PRIVATE_H */
-36
drivers/net/phy/mdio_bus.c
··· 29 29 #include <linux/string.h> 30 30 #include <linux/uaccess.h> 31 31 #include <linux/unistd.h> 32 - #include "mdio-private.h" 33 32 34 33 #define CREATE_TRACE_POINTS 35 34 #include <trace/events/mdio.h> 36 - 37 - int mdiobus_register_device(struct mdio_device *mdiodev) 38 - { 39 - int err; 40 - 41 - if (mdiodev->bus->mdio_map[mdiodev->addr]) 42 - return -EBUSY; 43 - 44 - if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) { 45 - err = mdio_device_register_reset(mdiodev); 46 - if (err) 47 - return err; 48 - 49 - /* Assert the reset signal */ 50 - mdio_device_reset(mdiodev, 1); 51 - } 52 - 53 - mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev; 54 - 55 - return 0; 56 - } 57 - EXPORT_SYMBOL(mdiobus_register_device); 58 - 59 - int mdiobus_unregister_device(struct mdio_device *mdiodev) 60 - { 61 - if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev) 62 - return -EINVAL; 63 - 64 - mdio_device_unregister_reset(mdiodev); 65 - 66 - mdiodev->bus->mdio_map[mdiodev->addr] = NULL; 67 - 68 - return 0; 69 - } 70 - EXPORT_SYMBOL(mdiobus_unregister_device); 71 35 72 36 static struct mdio_device *mdiobus_find_device(struct mii_bus *bus, int addr) 73 37 {
+36 -3
drivers/net/phy/mdio_device.c
··· 22 22 #include <linux/string.h> 23 23 #include <linux/unistd.h> 24 24 #include <linux/property.h> 25 - #include "mdio-private.h" 25 + #include "phylib-internal.h" 26 26 27 27 /** 28 28 * mdio_device_register_reset - Read and initialize the reset properties of ··· 31 31 * 32 32 * Return: Zero if successful, negative error code on failure 33 33 */ 34 - int mdio_device_register_reset(struct mdio_device *mdiodev) 34 + static int mdio_device_register_reset(struct mdio_device *mdiodev) 35 35 { 36 36 struct reset_control *reset; 37 37 ··· 67 67 * an mdio device 68 68 * @mdiodev: mdio_device structure 69 69 */ 70 - void mdio_device_unregister_reset(struct mdio_device *mdiodev) 70 + static void mdio_device_unregister_reset(struct mdio_device *mdiodev) 71 71 { 72 72 gpiod_put(mdiodev->reset_gpio); 73 73 mdiodev->reset_gpio = NULL; ··· 188 188 mdiobus_unregister_device(mdiodev); 189 189 } 190 190 EXPORT_SYMBOL(mdio_device_remove); 191 + 192 + int mdiobus_register_device(struct mdio_device *mdiodev) 193 + { 194 + int err; 195 + 196 + if (mdiodev->bus->mdio_map[mdiodev->addr]) 197 + return -EBUSY; 198 + 199 + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) { 200 + err = mdio_device_register_reset(mdiodev); 201 + if (err) 202 + return err; 203 + 204 + /* Assert the reset signal */ 205 + mdio_device_reset(mdiodev, 1); 206 + } 207 + 208 + mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev; 209 + 210 + return 0; 211 + } 212 + 213 + int mdiobus_unregister_device(struct mdio_device *mdiodev) 214 + { 215 + if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev) 216 + return -EINVAL; 217 + 218 + mdio_device_unregister_reset(mdiodev); 219 + 220 + mdiodev->bus->mdio_map[mdiodev->addr] = NULL; 221 + 222 + return 0; 223 + } 191 224 192 225 /** 193 226 * mdio_probe - probe an MDIO device
+4
drivers/net/phy/phylib-internal.h
··· 6 6 #ifndef __PHYLIB_INTERNAL_H 7 7 #define __PHYLIB_INTERNAL_H 8 8 9 + struct mdio_device; 9 10 struct phy_device; 10 11 11 12 /* ··· 20 19 void of_set_phy_timing_role(struct phy_device *phydev); 21 20 int phy_speed_down_core(struct phy_device *phydev); 22 21 void phy_check_downshift(struct phy_device *phydev); 22 + 23 + int mdiobus_register_device(struct mdio_device *mdiodev); 24 + int mdiobus_unregister_device(struct mdio_device *mdiodev); 23 25 24 26 int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv); 25 27
+2 -2
drivers/phy/broadcom/Kconfig
··· 52 52 tristate "Broadcom Northstar USB 3.0 PHY Driver" 53 53 depends on ARCH_BCM_IPROC || COMPILE_TEST 54 54 depends on HAS_IOMEM && OF 55 - depends on MDIO_BUS 55 + depends on PHYLIB 56 56 select GENERIC_PHY 57 57 help 58 58 Enable this to support Broadcom USB 3.0 PHY connected to the USB ··· 60 60 61 61 config PHY_NS2_PCIE 62 62 tristate "Broadcom Northstar2 PCIe PHY driver" 63 - depends on (OF && MDIO_BUS_MUX_BCM_IPROC) || (COMPILE_TEST && MDIO_BUS) 63 + depends on (OF && MDIO_BUS_MUX_BCM_IPROC) || (COMPILE_TEST && PHYLIB) 64 64 select GENERIC_PHY 65 65 default ARCH_BCM_IPROC 66 66 help
-2
include/linux/mdio.h
··· 688 688 val); 689 689 } 690 690 691 - int mdiobus_register_device(struct mdio_device *mdiodev); 692 - int mdiobus_unregister_device(struct mdio_device *mdiodev); 693 691 bool mdiobus_is_registered_device(struct mii_bus *bus, int addr); 694 692 struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr); 695 693