Skip to content

Commit 2c8045d

Browse files
hkallweitvinodkoul
authored andcommitted
phy: amlogic: fix error path in phy_g12a_usb3_pcie_probe()
If clk_prepare_enable() fails we call clk_disable_unprepare() in the error path what results in a warning that the clock is disabled and unprepared already. And if we fail later in phy_g12a_usb3_pcie_probe() then we bail out w/o calling clk_disable_unprepare(). This patch fixes both errors. Fixes: 36077e1 ("phy: amlogic: Add Amlogic G12A USB3 + PCIE Combo PHY Driver") Signed-off-by: Heiner Kallweit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent ce88613 commit 2c8045d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,28 +414,32 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
414414

415415
ret = clk_prepare_enable(priv->clk_ref);
416416
if (ret)
417-
goto err_disable_clk_ref;
417+
return ret;
418418

419419
priv->reset = devm_reset_control_array_get_exclusive(dev);
420-
if (IS_ERR(priv->reset))
421-
return PTR_ERR(priv->reset);
420+
if (IS_ERR(priv->reset)) {
421+
ret = PTR_ERR(priv->reset);
422+
goto err_disable_clk_ref;
423+
}
422424

423425
priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops);
424426
if (IS_ERR(priv->phy)) {
425427
ret = PTR_ERR(priv->phy);
426-
if (ret != -EPROBE_DEFER)
427-
dev_err(dev, "failed to create PHY\n");
428-
429-
return ret;
428+
dev_err_probe(dev, ret, "failed to create PHY\n");
429+
goto err_disable_clk_ref;
430430
}
431431

432432
phy_set_drvdata(priv->phy, priv);
433433
dev_set_drvdata(dev, priv);
434434

435435
phy_provider = devm_of_phy_provider_register(dev,
436436
phy_g12a_usb3_pcie_xlate);
437+
if (IS_ERR(phy_provider)) {
438+
ret = PTR_ERR(phy_provider);
439+
goto err_disable_clk_ref;
440+
}
437441

438-
return PTR_ERR_OR_ZERO(phy_provider);
442+
return 0;
439443

440444
err_disable_clk_ref:
441445
clk_disable_unprepare(priv->clk_ref);

0 commit comments

Comments
 (0)