aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBuday Csaba <[email protected]>2025-08-07 13:54:49 +0000
committerPaolo Abeni <[email protected]>2025-08-12 10:32:58 +0000
commit8ea25274ebaf2f6be8be374633b2ed8348ec0e70 (patch)
tree268239bc003d5f6378fbe186b5036a35e4f992a2
parentnet: phy: nxp-c45-tja11xx: fix the PHY ID mismatch issue when using C45 (diff)
downloadkernel-8ea25274ebaf2f6be8be374633b2ed8348ec0e70.tar.gz
kernel-8ea25274ebaf2f6be8be374633b2ed8348ec0e70.zip
net: mdiobus: release reset_gpio in mdiobus_unregister_device()
reset_gpio is claimed in mdiobus_register_device(), but it is not released in mdiobus_unregister_device(). It is instead only released when the whole MDIO bus is unregistered. When a device uses the reset_gpio property, it becomes impossible to unregister it and register it again, because the GPIO remains claimed. This patch resolves that issue. Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support") # see notes Reviewed-by: Andrew Lunn <[email protected]> Cc: Csókás Bence <[email protected]> [ csokas.bence: Resolve rebase conflict and clarify msg ] Signed-off-by: Buday Csaba <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
-rw-r--r--drivers/net/phy/mdio_bus.c1
-rw-r--r--drivers/net/phy/mdio_bus_provider.c3
2 files changed, 1 insertions, 3 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index fda2e27c1810..cad6ed3aa10b 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -91,6 +91,7 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev)
if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
return -EINVAL;
+ gpiod_put(mdiodev->reset_gpio);
reset_control_put(mdiodev->reset_ctrl);
mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
diff --git a/drivers/net/phy/mdio_bus_provider.c b/drivers/net/phy/mdio_bus_provider.c
index 48dc4bf85125..f43973e73ea3 100644
--- a/drivers/net/phy/mdio_bus_provider.c
+++ b/drivers/net/phy/mdio_bus_provider.c
@@ -443,9 +443,6 @@ void mdiobus_unregister(struct mii_bus *bus)
if (!mdiodev)
continue;
- if (mdiodev->reset_gpio)
- gpiod_put(mdiodev->reset_gpio);
-
mdiodev->device_remove(mdiodev);
mdiodev->device_free(mdiodev);
}