Commit bb70d1aa authored by Anand Moon's avatar Anand Moon Committed by Vinod Koul
Browse files

phy: rockchip-pcie: Refactor mutex handling in rockchip_pcie_phy_power_off()



Refactor the mutex handling in the rockchip_pcie_phy_power_off() function
to improve code readability and maintainability. The goto statement has
been removed, and the mutex_unlock call is now directly within the
conditional block.

Return the result of reset_control_assert() function, with 0 indicating
success and an error code indicating failure

Signed-off-by: default avatarAnand Moon <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20241012071919.3726-5-linux.amoon@gmail.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent cb0ba26a
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -132,20 +132,14 @@ static int rockchip_pcie_phy_power_off(struct phy *phy)
				   PHY_LANE_IDLE_MASK,
				   PHY_LANE_IDLE_A_SHIFT + inst->index));

	if (--rk_phy->pwr_cnt)
		goto err_out;
	if (--rk_phy->pwr_cnt) {
		mutex_unlock(&rk_phy->pcie_mutex);
		return 0;
	}

	err = reset_control_assert(rk_phy->phy_rst);
	if (err) {
		dev_err(&phy->dev, "assert phy_rst err %d\n", err);
		goto err_restore;
	}

err_out:
	mutex_unlock(&rk_phy->pcie_mutex);
	return 0;

err_restore:
		rk_phy->pwr_cnt++;
		regmap_write(rk_phy->reg_base,
			     rk_phy->phy_data->pcie_laneoff,
@@ -156,6 +150,10 @@ static int rockchip_pcie_phy_power_off(struct phy *phy)
		return err;
	}

	mutex_unlock(&rk_phy->pcie_mutex);
	return err;
}

static int rockchip_pcie_phy_power_on(struct phy *phy)
{
	struct phy_pcie_instance *inst = phy_get_drvdata(phy);