Commit 375904e3 authored by Yang Yingliang's avatar Yang Yingliang Committed by Mark Brown

ASoC: hisilicon: fix missing clk_disable_unprepare() on error in hi6210_i2s_startup()

After calling clk_prepare_enable(), clk_disable_unprepare() need
be called when calling clk_set_rate() failed.

Fixes: 0bf750f4 ("ASoC: hisilicon: Add hi6210 i2s audio driver")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210518044514.607010-1-yangyingliang@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5a3f869c
...@@ -102,18 +102,15 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream, ...@@ -102,18 +102,15 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,
for (n = 0; n < i2s->clocks; n++) { for (n = 0; n < i2s->clocks; n++) {
ret = clk_prepare_enable(i2s->clk[n]); ret = clk_prepare_enable(i2s->clk[n]);
if (ret) { if (ret)
while (n--) goto err_unprepare_clk;
clk_disable_unprepare(i2s->clk[n]);
return ret;
}
} }
ret = clk_set_rate(i2s->clk[CLK_I2S_BASE], 49152000); ret = clk_set_rate(i2s->clk[CLK_I2S_BASE], 49152000);
if (ret) { if (ret) {
dev_err(i2s->dev, "%s: setting 49.152MHz base rate failed %d\n", dev_err(i2s->dev, "%s: setting 49.152MHz base rate failed %d\n",
__func__, ret); __func__, ret);
return ret; goto err_unprepare_clk;
} }
/* enable clock before frequency division */ /* enable clock before frequency division */
...@@ -165,6 +162,11 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream, ...@@ -165,6 +162,11 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,
hi6210_write_reg(i2s, HII2S_SW_RST_N, val); hi6210_write_reg(i2s, HII2S_SW_RST_N, val);
return 0; return 0;
err_unprepare_clk:
while (n--)
clk_disable_unprepare(i2s->clk[n]);
return ret;
} }
static void hi6210_i2s_shutdown(struct snd_pcm_substream *substream, static void hi6210_i2s_shutdown(struct snd_pcm_substream *substream,
......
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