Bug 188561

Summary: Function wm831x_clkout_is_prepared() returns an improper value
Product: Drivers Reporter: bianpan (bianpan2010)
Component: OtherAssignee: drivers_other
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: linux-4.9-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: The patch fixes the bug

Description bianpan 2016-11-25 10:33:42 UTC
In function wm831x_clkout_is_prepared() defined in file drivers/clk/clk-wm831x.c, it returns true (at line 246) when the call to wm831x_reg_read() (at line 242) fails. I am not sure whether it is a bug. From the name of the function, I guess "true" indicates that the wm831x_clkout is already prepared. So, when wm831x_reg_read() fails, returns "true" seems improper. Related codes are shown as follows.

wm831x_clkout_is_prepared @@ drivers/clk/clk-wm831x.c
235 static int wm831x_clkout_is_prepared(struct clk_hw *hw)
236 {
237     struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
238                           clkout_hw);
239     struct wm831x *wm831x = clkdata->wm831x;
240     int ret;
241 
242     ret = wm831x_reg_read(wm831x, WM831X_CLOCK_CONTROL_1);
243     if (ret < 0) {
244         dev_err(wm831x->dev, "Unable to read CLOCK_CONTROL_1: %d\n",
245             ret);
246         return true;
247     }
248 
249     return (ret & WM831X_CLKOUT_ENA) != 0;
250 }

Thanks very much!
Comment 1 bianpan 2017-05-11 09:23:48 UTC
Created attachment 256375 [details]
The patch fixes the bug

The patch has been merged into the lastest version. So I will close the bug.