Skip to content

Commit 67e9bf0

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: rt5514: 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 71d322f commit 67e9bf0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sound/soc/codecs/rt5514.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,6 @@ static int rt5514_set_bias_level(struct snd_soc_component *component,
10541054

10551055
switch (level) {
10561056
case SND_SOC_BIAS_PREPARE:
1057-
if (IS_ERR(rt5514->mclk))
1058-
break;
1059-
10601057
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
10611058
clk_disable_unprepare(rt5514->mclk);
10621059
} else {
@@ -1097,9 +1094,9 @@ static int rt5514_probe(struct snd_soc_component *component)
10971094
struct platform_device *pdev = container_of(component->dev,
10981095
struct platform_device, dev);
10991096

1100-
rt5514->mclk = devm_clk_get(component->dev, "mclk");
1101-
if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
1102-
return -EPROBE_DEFER;
1097+
rt5514->mclk = devm_clk_get_optional(component->dev, "mclk");
1098+
if (IS_ERR(rt5514->mclk))
1099+
return PTR_ERR(rt5514->mclk);
11031100

11041101
if (rt5514->pdata.dsp_calib_clk_name) {
11051102
rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev,

0 commit comments

Comments
 (0)