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>
This commit is contained in:
Buday Csaba 2025-11-18 14:58:52 +01:00 committed by Jakub Kicinski
parent 9e203721ec
commit 02aeff20e8
3 changed files with 42 additions and 29 deletions

View File

@ -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 */

View File

@ -29,37 +29,11 @@
#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;

View 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;