Skip to content

Commit f76de61

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: rt5616: 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. 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 67e9bf0 commit f76de61

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sound/soc/codecs/rt5616.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,9 +1174,6 @@ static int rt5616_set_bias_level(struct snd_soc_component *component,
11741174
* away from ON. Disable the clock in that case, otherwise
11751175
* enable it.
11761176
*/
1177-
if (IS_ERR(rt5616->mclk))
1178-
break;
1179-
11801177
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
11811178
clk_disable_unprepare(rt5616->mclk);
11821179
} else {
@@ -1225,9 +1222,9 @@ static int rt5616_probe(struct snd_soc_component *component)
12251222
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
12261223

12271224
/* Check if MCLK provided */
1228-
rt5616->mclk = devm_clk_get(component->dev, "mclk");
1229-
if (PTR_ERR(rt5616->mclk) == -EPROBE_DEFER)
1230-
return -EPROBE_DEFER;
1225+
rt5616->mclk = devm_clk_get_optional(component->dev, "mclk");
1226+
if (IS_ERR(rt5616->mclk))
1227+
return PTR_ERR(rt5616->mclk);
12311228

12321229
rt5616->component = component;
12331230

0 commit comments

Comments
 (0)