Skip to content

Commit d70b591

Browse files
Buday Csabagregkh
authored andcommitted
net: mdiobus: release reset_gpio in mdiobus_unregister_device()
commit 8ea2527 upstream. 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: bafbdd5 ("phylib: Add device reset GPIO support") # see notes Reviewed-by: Andrew Lunn <andrew@lunn.ch> Cc: Csókás Bence <csokas.bence@prolan.hu> [ csokas.bence: Resolve rebase conflict and clarify msg ] Signed-off-by: Buday Csaba <buday.csaba@prolan.hu> Link: https://patch.msgid.link/20250807135449.254254-2-csokas.bence@prolan.hu Signed-off-by: Paolo Abeni <pabeni@redhat.com> [ csokas.bence: Use the v1 patch on top of 6.6, as specified in notes ] Signed-off-by: Bence Csókás <csokas.bence@prolan.hu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cce57cd commit d70b591

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/net/phy/mdio_bus.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev)
9999
if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
100100
return -EINVAL;
101101

102+
gpiod_put(mdiodev->reset_gpio);
102103
reset_control_put(mdiodev->reset_ctrl);
103104

104105
mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
@@ -775,9 +776,6 @@ void mdiobus_unregister(struct mii_bus *bus)
775776
if (!mdiodev)
776777
continue;
777778

778-
if (mdiodev->reset_gpio)
779-
gpiod_put(mdiodev->reset_gpio);
780-
781779
mdiodev->device_remove(mdiodev);
782780
mdiodev->device_free(mdiodev);
783781
}

0 commit comments

Comments
 (0)