]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: mdio: move device reset functions to mdio_device.c
authorBuday Csaba <buday.csaba@prolan.hu>
Tue, 18 Nov 2025 13:58:52 +0000 (14:58 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 21 Nov 2025 01:41:39 +0000 (17:41 -0800)
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>
drivers/net/phy/mdio-private.h [new file with mode: 0644]
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_device.c

diff --git a/drivers/net/phy/mdio-private.h b/drivers/net/phy/mdio-private.h
new file mode 100644 (file)
index 0000000..44e2e09
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __MDIO_PRIVATE_H
+#define __MDIO_PRIVATE_H
+
+/* MDIO internal helpers
+ */
+
+int mdio_device_register_reset(struct mdio_device *mdiodev);
+int mdio_device_register_gpiod(struct mdio_device *mdiodev);
+
+#endif /* __MDIO_PRIVATE_H */
index 4354241137d50d070883c0ad78b465f71114573b..575b8bb5bb7a97346c7e0617446aa85a3d47d326 100644 (file)
 #include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
+#include "mdio-private.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/mdio.h>
 
-static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
-{
-       /* Deassert the optional reset signal */
-       mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev,
-                                                "reset", GPIOD_OUT_LOW);
-       if (IS_ERR(mdiodev->reset_gpio))
-               return PTR_ERR(mdiodev->reset_gpio);
-
-       if (mdiodev->reset_gpio)
-               gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset");
-
-       return 0;
-}
-
-static int mdiobus_register_reset(struct mdio_device *mdiodev)
-{
-       struct reset_control *reset;
-
-       reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy");
-       if (IS_ERR(reset))
-               return PTR_ERR(reset);
-
-       mdiodev->reset_ctrl = reset;
-
-       return 0;
-}
-
 int mdiobus_register_device(struct mdio_device *mdiodev)
 {
        int err;
@@ -68,11 +42,11 @@ int mdiobus_register_device(struct mdio_device *mdiodev)
                return -EBUSY;
 
        if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) {
-               err = mdiobus_register_gpiod(mdiodev);
+               err = mdio_device_register_gpiod(mdiodev);
                if (err)
                        return err;
 
-               err = mdiobus_register_reset(mdiodev);
+               err = mdio_device_register_reset(mdiodev);
                if (err) {
                        gpiod_put(mdiodev->reset_gpio);
                        mdiodev->reset_gpio = NULL;
index f64176e0e197f2f84f826255667793ff60c81152..0e04bddd3619145dc3e2b1a34f633d165acf7561 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/string.h>
 #include <linux/unistd.h>
 #include <linux/property.h>
+#include "mdio-private.h"
 
 void mdio_device_free(struct mdio_device *mdiodev)
 {
@@ -118,6 +119,33 @@ void mdio_device_remove(struct mdio_device *mdiodev)
 }
 EXPORT_SYMBOL(mdio_device_remove);
 
+int mdio_device_register_gpiod(struct mdio_device *mdiodev)
+{
+       /* Deassert the optional reset signal */
+       mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev,
+                                                "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(mdiodev->reset_gpio))
+               return PTR_ERR(mdiodev->reset_gpio);
+
+       if (mdiodev->reset_gpio)
+               gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset");
+
+       return 0;
+}
+
+int mdio_device_register_reset(struct mdio_device *mdiodev)
+{
+       struct reset_control *reset;
+
+       reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy");
+       if (IS_ERR(reset))
+               return PTR_ERR(reset);
+
+       mdiodev->reset_ctrl = reset;
+
+       return 0;
+}
+
 void mdio_device_reset(struct mdio_device *mdiodev, int value)
 {
        unsigned int d;