Skip to content

Commit e2cb72d

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: da7213: 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 <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240221152516.852353-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b96ccdc commit e2cb72d

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

sound/soc/codecs/da7213.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,18 +2101,14 @@ static int da7213_probe(struct snd_soc_component *component)
21012101
pm_runtime_put_sync(component->dev);
21022102

21032103
/* Check if MCLK provided */
2104-
da7213->mclk = devm_clk_get(component->dev, "mclk");
2105-
if (IS_ERR(da7213->mclk)) {
2106-
if (PTR_ERR(da7213->mclk) != -ENOENT)
2107-
return PTR_ERR(da7213->mclk);
2108-
else
2109-
da7213->mclk = NULL;
2110-
} else {
2104+
da7213->mclk = devm_clk_get_optional(component->dev, "mclk");
2105+
if (IS_ERR(da7213->mclk))
2106+
return PTR_ERR(da7213->mclk);
2107+
if (da7213->mclk)
21112108
/* Do automatic PLL handling assuming fixed clock until
21122109
* set_pll() has been called. This makes the codec usable
21132110
* with the simple-audio-card driver. */
21142111
da7213->fixed_clk_auto_pll = true;
2115-
}
21162112

21172113
/* Default infinite tone gen, start/stop by Kcontrol */
21182114
snd_soc_component_write(component, DA7213_TONE_GEN_CYCLES, DA7213_BEEP_CYCLES_MASK);

0 commit comments

Comments
 (0)