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

Configure Feed

Select the types of activity you want to include in your feed.

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: Anand Moon <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20241012071919.3726-5-linux.amoon@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Anand Moon and committed by
Vinod Koul
bb70d1aa cb0ba26a

+12 -14
+12 -14
drivers/phy/rockchip/phy-rockchip-pcie.c
··· 132 132 PHY_LANE_IDLE_MASK, 133 133 PHY_LANE_IDLE_A_SHIFT + inst->index)); 134 134 135 - if (--rk_phy->pwr_cnt) 136 - goto err_out; 135 + if (--rk_phy->pwr_cnt) { 136 + mutex_unlock(&rk_phy->pcie_mutex); 137 + return 0; 138 + } 137 139 138 140 err = reset_control_assert(rk_phy->phy_rst); 139 141 if (err) { 140 142 dev_err(&phy->dev, "assert phy_rst err %d\n", err); 141 - goto err_restore; 143 + rk_phy->pwr_cnt++; 144 + regmap_write(rk_phy->reg_base, 145 + rk_phy->phy_data->pcie_laneoff, 146 + HIWORD_UPDATE(!PHY_LANE_IDLE_OFF, 147 + PHY_LANE_IDLE_MASK, 148 + PHY_LANE_IDLE_A_SHIFT + inst->index)); 149 + mutex_unlock(&rk_phy->pcie_mutex); 150 + return err; 142 151 } 143 152 144 - err_out: 145 - mutex_unlock(&rk_phy->pcie_mutex); 146 - return 0; 147 - 148 - err_restore: 149 - rk_phy->pwr_cnt++; 150 - regmap_write(rk_phy->reg_base, 151 - rk_phy->phy_data->pcie_laneoff, 152 - HIWORD_UPDATE(!PHY_LANE_IDLE_OFF, 153 - PHY_LANE_IDLE_MASK, 154 - PHY_LANE_IDLE_A_SHIFT + inst->index)); 155 153 mutex_unlock(&rk_phy->pcie_mutex); 156 154 return err; 157 155 }