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

net: mdio: move device reset functions to mdio_device.c

The functions mdiobus_register_gpiod() and mdiobus_register_reset()
handle the mdio device reset initialization, which belong to
mdio_device.c.
Move them from mdio_bus.c to mdio_device.c, and rename them to match
the corresponding source file: mdio_device_register_gpio() and
mdio_device_register_reset().
Remove 'static' qualifiers and declare them in
drivers/net/phy/mdio-private.h (new header file).

Signed-off-by: Buday Csaba <buday.csaba@prolan.hu>
Link: https://patch.msgid.link/5f684838ee897130f21b21beb07695eea4af8988.1763473655.git.buday.csaba@prolan.hu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Buday Csaba and committed by
Jakub Kicinski
02aeff20 9e203721

+42 -29
+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 + int mdio_device_register_gpiod(struct mdio_device *mdiodev); 10 + 11 + #endif /* __MDIO_PRIVATE_H */
+3 -29
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" 32 33 33 34 #define CREATE_TRACE_POINTS 34 35 #include <trace/events/mdio.h> 35 - 36 - static int mdiobus_register_gpiod(struct mdio_device *mdiodev) 37 - { 38 - /* Deassert the optional reset signal */ 39 - mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev, 40 - "reset", GPIOD_OUT_LOW); 41 - if (IS_ERR(mdiodev->reset_gpio)) 42 - return PTR_ERR(mdiodev->reset_gpio); 43 - 44 - if (mdiodev->reset_gpio) 45 - gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); 46 - 47 - return 0; 48 - } 49 - 50 - static int mdiobus_register_reset(struct mdio_device *mdiodev) 51 - { 52 - struct reset_control *reset; 53 - 54 - reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); 55 - if (IS_ERR(reset)) 56 - return PTR_ERR(reset); 57 - 58 - mdiodev->reset_ctrl = reset; 59 - 60 - return 0; 61 - } 62 36 63 37 int mdiobus_register_device(struct mdio_device *mdiodev) 64 38 { ··· 42 68 return -EBUSY; 43 69 44 70 if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) { 45 - err = mdiobus_register_gpiod(mdiodev); 71 + err = mdio_device_register_gpiod(mdiodev); 46 72 if (err) 47 73 return err; 48 74 49 - err = mdiobus_register_reset(mdiodev); 75 + err = mdio_device_register_reset(mdiodev); 50 76 if (err) { 51 77 gpiod_put(mdiodev->reset_gpio); 52 78 mdiodev->reset_gpio = NULL;
+28
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 26 26 27 void mdio_device_free(struct mdio_device *mdiodev) 27 28 { ··· 118 117 mdiobus_unregister_device(mdiodev); 119 118 } 120 119 EXPORT_SYMBOL(mdio_device_remove); 120 + 121 + int mdio_device_register_gpiod(struct mdio_device *mdiodev) 122 + { 123 + /* Deassert the optional reset signal */ 124 + mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev, 125 + "reset", GPIOD_OUT_LOW); 126 + if (IS_ERR(mdiodev->reset_gpio)) 127 + return PTR_ERR(mdiodev->reset_gpio); 128 + 129 + if (mdiodev->reset_gpio) 130 + gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); 131 + 132 + return 0; 133 + } 134 + 135 + int mdio_device_register_reset(struct mdio_device *mdiodev) 136 + { 137 + struct reset_control *reset; 138 + 139 + reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); 140 + if (IS_ERR(reset)) 141 + return PTR_ERR(reset); 142 + 143 + mdiodev->reset_ctrl = reset; 144 + 145 + return 0; 146 + } 121 147 122 148 void mdio_device_reset(struct mdio_device *mdiodev, int value) 123 149 {