Skip to content

Commit c3944ec

Browse files
mripardbebarino
authored andcommitted
clk: Fix phase init check
Commit 2760878 ("clk: Bail out when calculating phase fails during clk registration") introduced a check on error values at the time the clock is registered to bail out when such an error occurs. However, it doesn't check whether the returned value is positive which will happen if the driver returns a non-zero phase. Since a phase is usually a non-zero positive number this ends up returning something that isn't 0 to the caller of __clk_core_init(), making most clks fail to register if they implement a phase clk op and return anything besides 0 for the phase. Fix this by returning the error if phase is less than zero or just return zero if the phase is a positive number. Fixes: 2760878 ("clk: Bail out when calculating phase fails during clk registration") Signed-off-by: Maxime Ripard <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Reported-by: "kernelci.org bot" <[email protected]> [[email protected]: Reword commit text to provide clarity] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2760878 commit c3944ec

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/clk/clk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,6 +3344,7 @@ static int __clk_core_init(struct clk_core *core)
33443344
int ret;
33453345
struct clk_core *parent;
33463346
unsigned long rate;
3347+
int phase;
33473348

33483349
if (!core)
33493350
return -EINVAL;
@@ -3457,8 +3458,9 @@ static int __clk_core_init(struct clk_core *core)
34573458
* Since a phase is by definition relative to its parent, just
34583459
* query the current clock phase, or just assume it's in phase.
34593460
*/
3460-
ret = clk_core_get_phase(core);
3461-
if (ret < 0) {
3461+
phase = clk_core_get_phase(core);
3462+
if (phase < 0) {
3463+
ret = phase;
34623464
pr_warn("%s: Failed to get phase for clk '%s'\n", __func__,
34633465
core->name);
34643466
goto out;

0 commit comments

Comments
 (0)