Skip to content

Commit 2560114

Browse files
claudiubezneabebarino
authored andcommitted
clk: si5341: return error if one synth clock registration fails
In case devm_clk_hw_register() fails for one of synth clocks the probe continues. Later on, when registering output clocks which have as parents all the synth clocks, in case there is registration failure for at least one synth clock the information passed to clk core for registering output clock is not right: init.num_parents is fixed but init.parents may contain an array with less parents. Fixes: 3044a86 ("clk: Add Si5341/Si5340 driver") Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent bb7d09d commit 2560114

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/clk/clk-si5341.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ static int si5341_probe(struct i2c_client *client)
15531553
struct clk_init_data init;
15541554
struct clk *input;
15551555
const char *root_clock_name;
1556-
const char *synth_clock_names[SI5341_NUM_SYNTH];
1556+
const char *synth_clock_names[SI5341_NUM_SYNTH] = { NULL };
15571557
int err;
15581558
unsigned int i;
15591559
struct clk_si5341_output_config config[SI5341_MAX_NUM_OUTPUTS];
@@ -1705,6 +1705,7 @@ static int si5341_probe(struct i2c_client *client)
17051705
if (err) {
17061706
dev_err(&client->dev,
17071707
"synth N%u registration failed\n", i);
1708+
goto free_clk_names;
17081709
}
17091710
}
17101711

@@ -1782,16 +1783,17 @@ static int si5341_probe(struct i2c_client *client)
17821783
goto cleanup;
17831784
}
17841785

1786+
free_clk_names:
17851787
/* Free the names, clk framework makes copies */
17861788
for (i = 0; i < data->num_synth; ++i)
17871789
devm_kfree(&client->dev, (void *)synth_clock_names[i]);
17881790

1789-
return 0;
1790-
17911791
cleanup:
1792-
for (i = 0; i < SI5341_MAX_NUM_OUTPUTS; ++i) {
1793-
if (data->clk[i].vddo_reg)
1794-
regulator_disable(data->clk[i].vddo_reg);
1792+
if (err) {
1793+
for (i = 0; i < SI5341_MAX_NUM_OUTPUTS; ++i) {
1794+
if (data->clk[i].vddo_reg)
1795+
regulator_disable(data->clk[i].vddo_reg);
1796+
}
17951797
}
17961798
return err;
17971799
}

0 commit comments

Comments
 (0)