[PATCH] usb: dwc3: core: Use IS_ERR_VALUE() for ref_clk rate check
Jonas Karlman
jonas at kwiboo.se
Mon Feb 9 21:14:12 CET 2026
clk_get_rate() in U-Boot is documented to return clock rate on success,
0 for invalid clock and -ve error code for other errors. This differ
slightly from Linux where only >= 0 is returned from clk_get_rate().
Some clock drivers take advantage of this difference and may return -ve
error code for clocks not fully supported in U-Boot.
Use IS_ERR_VALUE() to check for an error code in addition to current
invalid clock check to fix broken and unpredicted behavior when clock
driver returns a -ve error code for the ref_clk.
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
drivers/usb/dwc3/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6f22b9232bad..5bfca580824a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -149,7 +149,7 @@ static void dwc3_ref_clk_period(struct dwc3 *dwc)
if (dwc->ref_clk) {
rate = clk_get_rate(dwc->ref_clk);
- if (!rate)
+ if (IS_ERR_VALUE(rate) || !rate)
return;
period = NSEC_PER_SEC / rate;
} else {
--
2.52.0
More information about the U-Boot
mailing list