From de854ba1b51179713472447192703026be510982 Mon Sep 17 00:00:00 2001
From: Misael Lopez Cruz <misael.lopez@ti.com>
Date: Mon, 28 Feb 2011 11:45:22 -0600
Subject: [PATCH 24/60] ASoC: twl6040: Update sysclk in hw_params

commit b2fe50715221b58bf41dbb745bc6b9b37c42a17d upstream

TWL6040 sysclk can be changed during hw_params() call depending
on the requested sample rate, which requires private sysclk value
to be updated as well.

Change-Id: I26cd8c6314b64946f073012c17455d4cfc9efafb
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Integrated-by: Jingdong Lu <jingdong.lu@windriver.com>
---
 sound/soc/codecs/twl6040.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index e477724..86b44a7 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -1340,7 +1340,7 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream,
 	struct twl6040 *twl6040 = codec->control_data;
 	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 	unsigned int sysclk;
-	int rate;
+	int rate, ret;
 
 	/* nothing to do for high-perf pll, it supports only 48 kHz */
 	if (priv->pll == TWL6040_HPPLL_ID)
@@ -1366,7 +1366,13 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	return twl6040_set_pll(twl6040, TWL6040_LPPLL_ID, priv->clk_in, sysclk);
+	ret = twl6040_set_pll(twl6040, TWL6040_LPPLL_ID, priv->clk_in, sysclk);
+	if (ret)
+		return ret;
+
+	priv->sysclk = twl6040_get_sysclk(twl6040);
+
+	return 0;
 }
 
 static int twl6040_prepare(struct snd_pcm_substream *substream,
-- 
1.7.4.1

