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: Use devm_clk_get_enabled() helper

Use devm_clk_get_enabled() instead of devm_clk_get() to make the code
cleaner and avoid calling clk_disable_unprepare(), as this is exactly
what this function does. Use the dev_err_probe() helper to simplify
error handling during probe.

Refactor the mutex handling in the rockchip_pcie_phy_init() 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-3-linux.amoon@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Anand Moon and committed by
Vinod Koul
e96397db 84de9180

+10 -24
+10 -24
drivers/phy/rockchip/phy-rockchip-pcie.c
··· 274 274 275 275 mutex_lock(&rk_phy->pcie_mutex); 276 276 277 - if (rk_phy->init_cnt++) 278 - goto err_out; 279 - 280 - err = clk_prepare_enable(rk_phy->clk_pciephy_ref); 281 - if (err) { 282 - dev_err(&phy->dev, "Fail to enable pcie ref clock.\n"); 283 - goto err_refclk; 277 + if (rk_phy->init_cnt++) { 278 + mutex_unlock(&rk_phy->pcie_mutex); 279 + return 0; 284 280 } 285 281 286 282 err = reset_control_assert(rk_phy->phy_rst); 287 283 if (err) { 288 284 dev_err(&phy->dev, "assert phy_rst err %d\n", err); 289 - goto err_reset; 285 + rk_phy->init_cnt--; 286 + mutex_unlock(&rk_phy->pcie_mutex); 287 + return err; 290 288 } 291 289 292 - err_out: 293 - mutex_unlock(&rk_phy->pcie_mutex); 294 - return 0; 295 - 296 - err_reset: 297 - 298 - clk_disable_unprepare(rk_phy->clk_pciephy_ref); 299 - err_refclk: 300 - rk_phy->init_cnt--; 301 290 mutex_unlock(&rk_phy->pcie_mutex); 302 291 return err; 303 292 } ··· 300 311 301 312 if (--rk_phy->init_cnt) 302 313 goto err_init_cnt; 303 - 304 - clk_disable_unprepare(rk_phy->clk_pciephy_ref); 305 314 306 315 err_init_cnt: 307 316 mutex_unlock(&rk_phy->pcie_mutex); ··· 362 375 return dev_err_probe(&pdev->dev, PTR_ERR(rk_phy->phy_rst), 363 376 "missing phy property for reset controller\n"); 364 377 365 - rk_phy->clk_pciephy_ref = devm_clk_get(dev, "refclk"); 366 - if (IS_ERR(rk_phy->clk_pciephy_ref)) { 367 - dev_err(dev, "refclk not found.\n"); 368 - return PTR_ERR(rk_phy->clk_pciephy_ref); 369 - } 378 + rk_phy->clk_pciephy_ref = devm_clk_get_enabled(dev, "refclk"); 379 + if (IS_ERR(rk_phy->clk_pciephy_ref)) 380 + return dev_err_probe(&pdev->dev, PTR_ERR(rk_phy->clk_pciephy_ref), 381 + "failed to get phyclk\n"); 370 382 371 383 /* parse #phy-cells to see if it's legacy PHY model */ 372 384 if (of_property_read_u32(dev->of_node, "#phy-cells", &phy_num))