Commit 8ea25274 authored by Buday Csaba's avatar Buday Csaba Committed by Paolo Abeni
Browse files

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: bafbdd52 ("phylib: Add device reset GPIO support") # see notes
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Cc: Csókás Bence <csokas.bence@prolan.hu>
[ csokas.bence: Resolve rebase conflict and clarify msg ]
Signed-off-by: default avatarBuday Csaba <buday.csaba@prolan.hu>
Link: https://patch.msgid.link/20250807135449.254254-2-csokas.bence@prolan.hu


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 8ee90742
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+0 −3
Original line number Diff line number Diff line
@@ -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);
	}