]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: mdiobus: release reset_gpio in mdiobus_unregister_device()
authorBuday Csaba <buday.csaba@prolan.hu>
Thu, 7 Aug 2025 13:54:49 +0000 (15:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:40:52 +0000 (18:40 +0200)
[ Upstream commit 8ea25274ebaf2f6be8be374633b2ed8348ec0e70 ]

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 <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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_bus_provider.c

index fda2e27c18105cff83292a2b6fbc4d989d1db576..cad6ed3aa10b643ad63fac15bfe7551446c8dca1 100644 (file)
@@ -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;
index 65850e36284de3c3ed5a215f1183f5d823869154..5401170f14e5a44c974aae07209c421e71311cd2 100644 (file)
@@ -444,9 +444,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);
        }