Skip to content

Commit bf900c8

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: rt5660: 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 6413849 commit bf900c8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sound/soc/codecs/rt5660.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,9 +1079,6 @@ static int rt5660_set_bias_level(struct snd_soc_component *component,
10791079
snd_soc_component_update_bits(component, RT5660_GEN_CTRL1,
10801080
RT5660_DIG_GATE_CTRL, RT5660_DIG_GATE_CTRL);
10811081

1082-
if (IS_ERR(rt5660->mclk))
1083-
break;
1084-
10851082
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
10861083
clk_disable_unprepare(rt5660->mclk);
10871084
} else {
@@ -1277,9 +1274,9 @@ static int rt5660_i2c_probe(struct i2c_client *i2c)
12771274
return -ENOMEM;
12781275

12791276
/* Check if MCLK provided */
1280-
rt5660->mclk = devm_clk_get(&i2c->dev, "mclk");
1281-
if (PTR_ERR(rt5660->mclk) == -EPROBE_DEFER)
1282-
return -EPROBE_DEFER;
1277+
rt5660->mclk = devm_clk_get_optional(&i2c->dev, "mclk");
1278+
if (IS_ERR(rt5660->mclk))
1279+
return PTR_ERR(rt5660->mclk);
12831280

12841281
i2c_set_clientdata(i2c, rt5660);
12851282

0 commit comments

Comments
 (0)