Commit 0db0c62c authored by Katsuhiro Suzuki's avatar Katsuhiro Suzuki Committed by Mark Brown

ASoC: es8316: fix redundant codes of clock

This patch removes redundant null checks for optional MCLK clock.
And fix DT binding document for changing clock property to optional
from required.
Signed-off-by: default avatarKatsuhiro Suzuki <katsuhiro@katsuster.net>
Link: https://lore.kernel.org/r/20190907163653.9382-1-katsuhiro@katsuster.netSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f4df4e40
...@@ -6,6 +6,9 @@ Required properties: ...@@ -6,6 +6,9 @@ Required properties:
- compatible : should be "everest,es8316" - compatible : should be "everest,es8316"
- reg : the I2C address of the device for I2C - reg : the I2C address of the device for I2C
Optional properties:
- clocks : a list of phandle, should contain entries for clock-names - clocks : a list of phandle, should contain entries for clock-names
- clock-names : should include as follows: - clock-names : should include as follows:
"mclk" : master clock (MCLK) of the device "mclk" : master clock (MCLK) of the device
......
...@@ -370,11 +370,9 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -370,11 +370,9 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
if (freq == 0) if (freq == 0)
return 0; return 0;
if (es8316->mclk) {
ret = clk_set_rate(es8316->mclk, freq); ret = clk_set_rate(es8316->mclk, freq);
if (ret) if (ret)
return ret; return ret;
}
/* Limit supported sample rates to ones that can be autodetected /* Limit supported sample rates to ones that can be autodetected
* by the codec running in slave mode. * by the codec running in slave mode.
...@@ -709,21 +707,19 @@ static int es8316_probe(struct snd_soc_component *component) ...@@ -709,21 +707,19 @@ static int es8316_probe(struct snd_soc_component *component)
es8316->component = component; es8316->component = component;
es8316->mclk = devm_clk_get(component->dev, "mclk"); es8316->mclk = devm_clk_get_optional(component->dev, "mclk");
if (PTR_ERR(es8316->mclk) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (IS_ERR(es8316->mclk)) { if (IS_ERR(es8316->mclk)) {
dev_err(component->dev, "clock is invalid, ignored\n"); dev_err(component->dev, "unable to get mclk\n");
es8316->mclk = NULL; return PTR_ERR(es8316->mclk);
} }
if (!es8316->mclk)
dev_warn(component->dev, "assuming static mclk\n");
if (es8316->mclk) {
ret = clk_prepare_enable(es8316->mclk); ret = clk_prepare_enable(es8316->mclk);
if (ret) { if (ret) {
dev_err(component->dev, "unable to enable clock\n"); dev_err(component->dev, "unable to enable mclk\n");
return ret; return ret;
} }
}
/* Reset codec and enable current state machine */ /* Reset codec and enable current state machine */
snd_soc_component_write(component, ES8316_RESET, 0x3f); snd_soc_component_write(component, ES8316_RESET, 0x3f);
...@@ -751,7 +747,6 @@ static void es8316_remove(struct snd_soc_component *component) ...@@ -751,7 +747,6 @@ static void es8316_remove(struct snd_soc_component *component)
{ {
struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
if (es8316->mclk)
clk_disable_unprepare(es8316->mclk); clk_disable_unprepare(es8316->mclk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment