Commit 61c7dbec authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsnd: don't call clk_disable_unprepare() if can't use

We need to care clock accessibility,
because we might can't use clock for some reasons.

It sets clk_rate for each clocks when enabled.
This means it doesn't have clk_rate if we can't use.
We can avoid to call clk_disable_unprepare() in such case.

Link: https://lore.kernel.org/r/CAMuHMdWvB+p=2JqTsO7bR8uJqKqO5A2XgXFXsVAjHk3hcxgcTw@mail.gmail.comReported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/87eejpgoi9.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 13733775
......@@ -366,25 +366,27 @@ void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable)
struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
struct device *dev = rsnd_priv_to_dev(priv);
struct clk *clk;
int i, ret;
int i;
for_each_rsnd_clk(clk, adg, i) {
ret = 0;
if (enable) {
ret = clk_prepare_enable(clk);
int ret = clk_prepare_enable(clk);
/*
* We shouldn't use clk_get_rate() under
* atomic context. Let's keep it when
* rsnd_adg_clk_enable() was called
*/
adg->clk_rate[i] = clk_get_rate(adg->clk[i]);
adg->clk_rate[i] = 0;
if (ret < 0)
dev_warn(dev, "can't use clk %d\n", i);
else
adg->clk_rate[i] = clk_get_rate(clk);
} else {
clk_disable_unprepare(clk);
if (adg->clk_rate[i])
clk_disable_unprepare(clk);
adg->clk_rate[i] = 0;
}
if (ret < 0)
dev_warn(dev, "can't use clk %d\n", i);
}
}
......
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