Skip to contentSkip to conversation

mdio_bus: don't use managed reset-controller

PATCH In review David Bauer 3 participants 3 messages Nov 22, 2019 – Nov 25, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mdio_bus: don't use managed reset-controller

Geert Uytterhoeven reported that using devm_reset_controller_get leads to a WARNING when probing a reset-controlled PHY. This is because the device devm_reset_controller_get gets supplied is not actually the one being probed.

Acquire an unmanaged reset-control as well as free the reset_control on unregister to fix this.

---
 drivers/net/phy/mdio_bus.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +4 -2
index dbacb0031877..229e480179ff 100644
@@ -62,8 +62,8 @@ static int mdiobus_register_reset(struct mdio_device *mdiodev)
 	struct reset_control *reset = NULL;
 
 	if (mdiodev->dev.of_node)
-		reset = devm_reset_control_get_exclusive(&mdiodev->dev,
-							 "phy");
+		reset = of_reset_control_get_exclusive(mdiodev->dev.of_node,
+						       "phy");
 	if (IS_ERR(reset)) {
 		if (PTR_ERR(reset) == -ENOENT || PTR_ERR(reset) == -ENOTSUPP)
 			reset = NULL;
@@ -107,6 +107,8 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev)
 	if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
 		return -EINVAL;
 
+	reset_control_put(mdiodev->reset_ctrl);
+
 	mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
 
 	return 0;
Signature · 1 line
2.24.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · David Bauer

Geert Uytterhoeven reported that using devm_reset_controller_get leads to a WARNING when probing a reset-controlled PHY. This is because the device devm_reset_controller_get gets supplied is not actually the one being probed.

Acquire an unmanaged reset-control as well as free the reset_control on unregister to fix this.

Andrew

maintainer
#2 lore raw
In reply to David Bauer

From: David Bauer <[email protected]>
Date: Fri, 22 Nov 2019 22:44:51 +0100

Quoted 11 lines

Geert Uytterhoeven reported that using devm_reset_controller_get leads to a WARNING when probing a reset-controlled PHY. This is because the device devm_reset_controller_get gets supplied is not actually the one being probed.

Acquire an unmanaged reset-control as well as free the reset_control on unregister to fix this.

Applied and queued up for -stable, thanks.