[PATCH] [phy/marvell] phy-pxa-28nm-usb2: Add error handling

From: Haoran Liu
Date: Wed Nov 29 2023 - 07:25:26 EST


This patch adds error handling to the mv_usb2_phy_28nm_init
function in drivers/phy/marvell/phy-pxa-28nm-usb2.c. The
function previously did not handle the potential failure of
the clk_prepare_enable call, which could result in unexpected
behavior if clock preparation failed.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
drivers/phy/marvell/phy-pxa-28nm-usb2.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/marvell/phy-pxa-28nm-usb2.c b/drivers/phy/marvell/phy-pxa-28nm-usb2.c
index 64afb82cf70e..93fea4f246a2 100644
--- a/drivers/phy/marvell/phy-pxa-28nm-usb2.c
+++ b/drivers/phy/marvell/phy-pxa-28nm-usb2.c
@@ -154,7 +154,11 @@ static int mv_usb2_phy_28nm_init(struct phy *phy)
u32 reg;
int ret;

- clk_prepare_enable(mv_phy->clk);
+ ret = clk_prepare_enable(mv_phy->clk);
+ if (ret) {
+ dev_err(&phy->dev, "Failed to enable clock: %d\n", ret);
+ return ret;
+ }

/* PHY_28NM_PLL_REG0 */
reg = readl(base + PHY_28NM_PLL_REG0) &
--
2.17.1