Commit b4351123 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Vinod Koul

phy: phy-rockchip-inno-usb2: simplify phy clock handling

Simplify phyclk handling by using devm_clk_get_optional_enabled to
acquire and enable the optional clock. This also fixes a resource
leak in driver remove path and adds proper error handling.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20230522170324.61349-6-sebastian.reichel@collabora.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 5ae6224b
...@@ -1390,24 +1390,22 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) ...@@ -1390,24 +1390,22 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
if (IS_ERR(rphy->phy_reset)) if (IS_ERR(rphy->phy_reset))
return PTR_ERR(rphy->phy_reset); return PTR_ERR(rphy->phy_reset);
rphy->clk = of_clk_get_by_name(np, "phyclk"); rphy->clk = devm_clk_get_optional_enabled(dev, "phyclk");
if (!IS_ERR(rphy->clk)) { if (IS_ERR(rphy->clk)) {
clk_prepare_enable(rphy->clk); return dev_err_probe(&pdev->dev, PTR_ERR(rphy->clk),
} else { "failed to get phyclk\n");
dev_info(&pdev->dev, "no phyclk specified\n");
rphy->clk = NULL;
} }
ret = rockchip_usb2phy_clk480m_register(rphy); ret = rockchip_usb2phy_clk480m_register(rphy);
if (ret) { if (ret) {
dev_err(dev, "failed to register 480m output clock\n"); dev_err(dev, "failed to register 480m output clock\n");
goto disable_clks; return ret;
} }
if (rphy->phy_cfg->phy_tuning) { if (rphy->phy_cfg->phy_tuning) {
ret = rphy->phy_cfg->phy_tuning(rphy); ret = rphy->phy_cfg->phy_tuning(rphy);
if (ret) if (ret)
goto disable_clks; return ret;
} }
index = 0; index = 0;
...@@ -1470,11 +1468,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) ...@@ -1470,11 +1468,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
put_child: put_child:
of_node_put(child_np); of_node_put(child_np);
disable_clks:
if (rphy->clk) {
clk_disable_unprepare(rphy->clk);
clk_put(rphy->clk);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment