]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
phy: phy-rockchip-inno-usb2: simplify phy clock handling
authorSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 21 Jan 2026 02:13:31 +0000 (21:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Feb 2026 15:44:21 +0000 (16:44 +0100)
[ Upstream commit b43511233c6e34b9c0d9a55e41b078d10e7d9ea6 ]

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: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20230522170324.61349-6-sebastian.reichel@collabora.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Stable-dep-of: e07dea3de508 ("phy: rockchip: inno-usb2: Fix a double free bug in rockchip_usb2phy_probe()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/phy/rockchip/phy-rockchip-inno-usb2.c

index 53743d87967b439c84eb5253dcec878e31dfbfa3..41eb99797a2c06845626ad0f42e038ad5ab3e9b6 100644 (file)
@@ -1273,18 +1273,16 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       rphy->clk = of_clk_get_by_name(np, "phyclk");
-       if (!IS_ERR(rphy->clk)) {
-               clk_prepare_enable(rphy->clk);
-       } else {
-               dev_info(&pdev->dev, "no phyclk specified\n");
-               rphy->clk = NULL;
+       rphy->clk = devm_clk_get_optional_enabled(dev, "phyclk");
+       if (IS_ERR(rphy->clk)) {
+               return dev_err_probe(&pdev->dev, PTR_ERR(rphy->clk),
+                                    "failed to get phyclk\n");
        }
 
        ret = rockchip_usb2phy_clk480m_register(rphy);
        if (ret) {
                dev_err(dev, "failed to register 480m output clock\n");
-               goto disable_clks;
+               return ret;
        }
 
        index = 0;
@@ -1347,11 +1345,6 @@ next_child:
 
 put_child:
        of_node_put(child_np);
-disable_clks:
-       if (rphy->clk) {
-               clk_disable_unprepare(rphy->clk);
-               clk_put(rphy->clk);
-       }
        return ret;
 }