Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 36077e16c050 ("phy: amlogic: Add Amlogic G12A USB3 + PCIE Combo PHY Driver")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/8e416f95-1084-ee28-860e-7884f7fa2e32@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Heiner Kallweit and committed by
Vinod Koul
2c8045d4 ce88613e

+12 -8
+12 -8
drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
··· 414 414 415 415 ret = clk_prepare_enable(priv->clk_ref); 416 416 if (ret) 417 - goto err_disable_clk_ref; 417 + return ret; 418 418 419 419 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 + } 422 424 423 425 priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops); 424 426 if (IS_ERR(priv->phy)) { 425 427 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; 430 430 } 431 431 432 432 phy_set_drvdata(priv->phy, priv); ··· 434 434 435 435 phy_provider = devm_of_phy_provider_register(dev, 436 436 phy_g12a_usb3_pcie_xlate); 437 + if (IS_ERR(phy_provider)) { 438 + ret = PTR_ERR(phy_provider); 439 + goto err_disable_clk_ref; 440 + } 437 441 438 - return PTR_ERR_OR_ZERO(phy_provider); 442 + return 0; 439 443 440 444 err_disable_clk_ref: 441 445 clk_disable_unprepare(priv->clk_ref);