Bug 188561 - Function wm831x_clkout_is_prepared() returns an improper value
Summary: Function wm831x_clkout_is_prepared() returns an improper value
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:33 UTC by bianpan
Modified: 2017-05-11 09:23 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
The patch fixes the bug (998 bytes, patch)
2017-05-11 09:23 UTC, bianpan
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.