From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH net-next 1/5] net: phy: move mdio_device reset handling functions in the code
Date: Sat, 7 Mar 2026 22:31:18 +0100 [thread overview]
Message-ID: <d7a8bf27-690b-4d69-8237-a8c12ffd28f8@gmail.com> (raw)
In-Reply-To: <8b34944e-3abf-4dd1-908d-c21d08c62c34@gmail.com>
In preparation of a follow-up patch this moves reset-related functions
in the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/mdio_device.c | 162 +++++++++++++++++-----------------
1 file changed, 81 insertions(+), 81 deletions(-)
diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index b8a5a183819..da4fb7484c7 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -24,6 +24,87 @@
#include <linux/property.h>
#include "mdio-private.h"
+/**
+ * mdio_device_register_reset - Read and initialize the reset properties of
+ * an mdio device
+ * @mdiodev: mdio_device structure
+ *
+ * Return: Zero if successful, negative error code on failure
+ */
+int mdio_device_register_reset(struct mdio_device *mdiodev)
+{
+ struct reset_control *reset;
+
+ /* 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");
+
+ reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy");
+ if (IS_ERR(reset)) {
+ gpiod_put(mdiodev->reset_gpio);
+ mdiodev->reset_gpio = NULL;
+ return PTR_ERR(reset);
+ }
+
+ mdiodev->reset_ctrl = reset;
+
+ /* Read optional firmware properties */
+ device_property_read_u32(&mdiodev->dev, "reset-assert-us",
+ &mdiodev->reset_assert_delay);
+ device_property_read_u32(&mdiodev->dev, "reset-deassert-us",
+ &mdiodev->reset_deassert_delay);
+
+ return 0;
+}
+
+/**
+ * mdio_device_unregister_reset - uninitialize the reset properties of
+ * an mdio device
+ * @mdiodev: mdio_device structure
+ */
+void mdio_device_unregister_reset(struct mdio_device *mdiodev)
+{
+ gpiod_put(mdiodev->reset_gpio);
+ mdiodev->reset_gpio = NULL;
+ reset_control_put(mdiodev->reset_ctrl);
+ mdiodev->reset_ctrl = NULL;
+ mdiodev->reset_assert_delay = 0;
+ mdiodev->reset_deassert_delay = 0;
+}
+
+void mdio_device_reset(struct mdio_device *mdiodev, int value)
+{
+ unsigned int d;
+
+ if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl)
+ return;
+
+ if (mdiodev->reset_state == value)
+ return;
+
+ if (mdiodev->reset_gpio)
+ gpiod_set_value_cansleep(mdiodev->reset_gpio, value);
+
+ if (mdiodev->reset_ctrl) {
+ if (value)
+ reset_control_assert(mdiodev->reset_ctrl);
+ else
+ reset_control_deassert(mdiodev->reset_ctrl);
+ }
+
+ d = value ? mdiodev->reset_assert_delay : mdiodev->reset_deassert_delay;
+ if (d)
+ fsleep(d);
+
+ mdiodev->reset_state = value;
+}
+EXPORT_SYMBOL(mdio_device_reset);
+
void mdio_device_free(struct mdio_device *mdiodev)
{
put_device(&mdiodev->dev);
@@ -108,87 +189,6 @@ void mdio_device_remove(struct mdio_device *mdiodev)
}
EXPORT_SYMBOL(mdio_device_remove);
-/**
- * mdio_device_register_reset - Read and initialize the reset properties of
- * an mdio device
- * @mdiodev: mdio_device structure
- *
- * Return: Zero if successful, negative error code on failure
- */
-int mdio_device_register_reset(struct mdio_device *mdiodev)
-{
- struct reset_control *reset;
-
- /* 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");
-
- reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy");
- if (IS_ERR(reset)) {
- gpiod_put(mdiodev->reset_gpio);
- mdiodev->reset_gpio = NULL;
- return PTR_ERR(reset);
- }
-
- mdiodev->reset_ctrl = reset;
-
- /* Read optional firmware properties */
- device_property_read_u32(&mdiodev->dev, "reset-assert-us",
- &mdiodev->reset_assert_delay);
- device_property_read_u32(&mdiodev->dev, "reset-deassert-us",
- &mdiodev->reset_deassert_delay);
-
- return 0;
-}
-
-/**
- * mdio_device_unregister_reset - uninitialize the reset properties of
- * an mdio device
- * @mdiodev: mdio_device structure
- */
-void mdio_device_unregister_reset(struct mdio_device *mdiodev)
-{
- gpiod_put(mdiodev->reset_gpio);
- mdiodev->reset_gpio = NULL;
- reset_control_put(mdiodev->reset_ctrl);
- mdiodev->reset_ctrl = NULL;
- mdiodev->reset_assert_delay = 0;
- mdiodev->reset_deassert_delay = 0;
-}
-
-void mdio_device_reset(struct mdio_device *mdiodev, int value)
-{
- unsigned int d;
-
- if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl)
- return;
-
- if (mdiodev->reset_state == value)
- return;
-
- if (mdiodev->reset_gpio)
- gpiod_set_value_cansleep(mdiodev->reset_gpio, value);
-
- if (mdiodev->reset_ctrl) {
- if (value)
- reset_control_assert(mdiodev->reset_ctrl);
- else
- reset_control_deassert(mdiodev->reset_ctrl);
- }
-
- d = value ? mdiodev->reset_assert_delay : mdiodev->reset_deassert_delay;
- if (d)
- fsleep(d);
-
- mdiodev->reset_state = value;
-}
-EXPORT_SYMBOL(mdio_device_reset);
-
/**
* mdio_probe - probe an MDIO device
* @dev: device to probe
--
2.53.0
next prev parent reply other threads:[~2026-03-07 21:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 21:30 [PATCH net-next 0/5] net: phy: further decouple provider from consumer part Heiner Kallweit
2026-03-07 21:31 ` Heiner Kallweit [this message]
2026-03-07 21:32 ` [PATCH net-next 2/5] net: phy: make mdio_device.c part of libphy Heiner Kallweit
2026-03-08 13:15 ` kernel test robot
2026-03-07 21:32 ` [PATCH net-next 3/5] net: phy: move (of_)mdio_find_bus to mdio_bus_provider.c Heiner Kallweit
2026-03-07 21:33 ` [PATCH net-next 4/5] net: phy: move registering mdio_bus_class and mdio_bus_type to libphy Heiner Kallweit
2026-03-07 21:34 ` [PATCH net-next 5/5] net: phy: move remaining provider code to mdio_bus_provider.c Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d7a8bf27-690b-4d69-8237-a8c12ffd28f8@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox