Message ID | 20240203-hisi-dwc3-v1-1-448050c7b690@outlook.com |
---|---|
State | New |
Delegated to: | Marek Vasut |
Headers | show |
Series | usb: dwv3: add glue driver for hi3798mv200 | expand |
On Sat, Feb 03, 2024 at 07:01:54AM +0800, Yang Xiwen via B4 Relay wrote: > From: Yang Xiwen <forbidden405@outlook.com> > > clk_get_rate() return -ve on error, not 0. Fix it by replacing judging > NULL with IS_ERR_VALUE(). ^^^^ s/NULL/zero/. I'd be surprised if clk_get_rate() *never* returns zero. The Linux kernel's clk_get_rate() function returns zero and not error codes, btw. regards, dan carpenter
On 2/5/2024 3:25 PM, Dan Carpenter wrote: > On Sat, Feb 03, 2024 at 07:01:54AM +0800, Yang Xiwen via B4 Relay wrote: >> From: Yang Xiwen <forbidden405@outlook.com> >> >> clk_get_rate() return -ve on error, not 0. Fix it by replacing judging >> NULL with IS_ERR_VALUE(). > ^^^^ > > s/NULL/zero/. > > I'd be surprised if clk_get_rate() *never* returns zero. The Linux > kernel's clk_get_rate() function returns zero and not error codes, btw. Yes, it's really surprising. U-Boot clk APIs are a little different from Linux kernel's. Sadly it's a bit too late to fix it since there are really plenty of existing users. Maybe we need to put some hints in the docs. > regards, > dan carpenter > >
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4b4fcd8a22..06ff68105e 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -137,7 +137,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)) return; period = NSEC_PER_SEC / rate; } else {