Commit f212c6d8 authored by Mans Rullgard's avatar Mans Rullgard Committed by Mark Brown
Browse files

ASoC: mxs-saif: fix clk_prepare() without matching clk_unprepare()



The clk_prepare() call in hw_params() has no matching clk_unprepare(),
leaving the clk with an ever-increasing prepare count.  Moreover,
hw_params() can be called multiple times which would again leave us
with a runaway prepare count.  Fix this by moving the clk_prepare()
call to the startup() function and adding a shutdown() function with
a matching clk_unprepare() as these operations are already correctly
bracketed by soc-core.

Signed-off-by: default avatarMans Rullgard <mans@mansr.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 92e963f5
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -381,9 +381,19 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream,
	__raw_writel(BM_SAIF_CTRL_CLKGATE,
	__raw_writel(BM_SAIF_CTRL_CLKGATE,
		saif->base + SAIF_CTRL + MXS_CLR_ADDR);
		saif->base + SAIF_CTRL + MXS_CLR_ADDR);


	clk_prepare(saif->clk);

	return 0;
	return 0;
}
}


static void mxs_saif_shutdown(struct snd_pcm_substream *substream,
			      struct snd_soc_dai *cpu_dai)
{
	struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);

	clk_unprepare(saif->clk);
}

/*
/*
 * Should only be called when port is inactive.
 * Should only be called when port is inactive.
 * although can be called multiple times by upper layers.
 * although can be called multiple times by upper layers.
@@ -424,8 +434,6 @@ static int mxs_saif_hw_params(struct snd_pcm_substream *substream,
		return ret;
		return ret;
	}
	}


	/* prepare clk in hw_param, enable in trigger */
	clk_prepare(saif->clk);
	if (saif != master_saif) {
	if (saif != master_saif) {
		/*
		/*
		* Set an initial clock rate for the saif internal logic to work
		* Set an initial clock rate for the saif internal logic to work
@@ -611,6 +619,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,


static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
	.startup = mxs_saif_startup,
	.startup = mxs_saif_startup,
	.shutdown = mxs_saif_shutdown,
	.trigger = mxs_saif_trigger,
	.trigger = mxs_saif_trigger,
	.prepare = mxs_saif_prepare,
	.prepare = mxs_saif_prepare,
	.hw_params = mxs_saif_hw_params,
	.hw_params = mxs_saif_hw_params,