mdio_bus: Simplify reset handling and extend to non-DT systems
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 13 Jan 2020 13:05:29 +0000 (14:05 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Jan 2020 19:03:10 +0000 (11:03 -0800)
Convert mdiobus_register_reset() from open-coded DT-only optional reset
handling to reset_control_get_optional_exclusive().  This not only
simplifies the code, but also adds support for lookup-based resets on
non-DT systems.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio_bus.c

index 229e480179ff1de40921764cfd4c066c82e38301..8d753bb07227e56127dcbba81ff51100aff65f62 100644 (file)
@@ -59,17 +59,11 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
 
 static int mdiobus_register_reset(struct mdio_device *mdiodev)
 {
-       struct reset_control *reset = NULL;
-
-       if (mdiodev->dev.of_node)
-               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;
-               else
-                       return PTR_ERR(reset);
-       }
+       struct reset_control *reset;
+
+       reset = reset_control_get_optional_exclusive(&mdiodev->dev, "phy");
+       if (IS_ERR(reset))
+               return PTR_ERR(reset);
 
        mdiodev->reset_ctrl = reset;