Skip to content

Commit 6413849

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: rt5640: Simplify mclk initialization
Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. rt5640_set_dai_sysclk() is an example of that - clk_set_rate() is not guarded by IS_ERR(). By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński <[email protected]> Signed-off-by: Cezary Rojewski <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f76de61 commit 6413849

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sound/soc/codecs/rt5640.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,9 +1949,6 @@ static int rt5640_set_bias_level(struct snd_soc_component *component,
19491949
* away from ON. Disable the clock in that case, otherwise
19501950
* enable it.
19511951
*/
1952-
if (IS_ERR(rt5640->mclk))
1953-
break;
1954-
19551952
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
19561953
clk_disable_unprepare(rt5640->mclk);
19571954
} else {
@@ -2661,9 +2658,9 @@ static int rt5640_probe(struct snd_soc_component *component)
26612658
u32 val;
26622659

26632660
/* Check if MCLK provided */
2664-
rt5640->mclk = devm_clk_get(component->dev, "mclk");
2665-
if (PTR_ERR(rt5640->mclk) == -EPROBE_DEFER)
2666-
return -EPROBE_DEFER;
2661+
rt5640->mclk = devm_clk_get_optional(component->dev, "mclk");
2662+
if (IS_ERR(rt5640->mclk))
2663+
return PTR_ERR(rt5640->mclk);
26672664

26682665
rt5640->component = component;
26692666

0 commit comments

Comments
 (0)