[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231129124043.33526-1-liuhaoran14@163.com>
Date: Wed, 29 Nov 2023 04:40:43 -0800
From: Haoran Liu <liuhaoran14@....com>
To: vkoul@...nel.org
Cc: kishon@...nel.org, linux-phy@...ts.infradead.org,
linux-kernel@...r.kernel.org, Haoran Liu <liuhaoran14@....com>
Subject: [PATCH] [phy/renesas] phy-rcar-gen2: Add error handling
This patch introduces error handling for the clk_prepare_enable
call in the rcar_gen2_phy_init function within
drivers/phy/renesas/phy-rcar-gen2.c. Previously, the function
lacked appropriate handling for potential failures of
clk_prepare_enable, which could lead to instability if the clock
preparation failed.
Signed-off-by: Haoran Liu <liuhaoran14@....com>
---
drivers/phy/renesas/phy-rcar-gen2.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index 507435af2656..c84eeaf1f607 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -80,6 +80,7 @@ static int rcar_gen2_phy_init(struct phy *p)
struct rcar_gen2_phy_driver *drv = channel->drv;
unsigned long flags;
u32 ugctrl2;
+ int ret;
/*
* Try to acquire exclusive access to PHY. The first driver calling
@@ -90,7 +91,11 @@ static int rcar_gen2_phy_init(struct phy *p)
if (cmpxchg(&channel->selected_phy, -1, phy->number) != -1)
return -EBUSY;
- clk_prepare_enable(drv->clk);
+ ret = clk_prepare_enable(drv->clk);
+ if (ret) {
+ dev_err(&p->dev, "Failed to enable clock: %d\n", ret);
+ return ret;
+ }
spin_lock_irqsave(&drv->lock, flags);
ugctrl2 = readl(drv->base + USBHS_UGCTRL2);
--
2.17.1
Powered by blists - more mailing lists