alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: sgtl5000: read chip revision for once
@ 2013-12-13  6:43 Shawn Guo
  2013-12-13  6:43 ` [PATCH 2/2] ASoC: sgtl5000: clean up sgtl5000_enable_regulators() Shawn Guo
  2013-12-16 20:15 ` [PATCH 1/2] ASoC: sgtl5000: read chip revision for once Mark Brown
  0 siblings, 2 replies; 18+ messages in thread
From: Shawn Guo @ 2013-12-13  6:43 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Xiubo Li, linux-arm-kernel, Shawn Guo

Store chip revision in struct sgtl5000_priv when sgtl5000_i2c_probe()
reads it out from register, so that we can use it in
sgtl5000_enable_regulators() with no need to read register again.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 sound/soc/codecs/sgtl5000.c |   16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 1f4093f..bd291d2 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -115,6 +115,7 @@ struct sgtl5000_priv {
 	struct ldo_regulator *ldo;
 	struct regmap *regmap;
 	struct clk *mclk;
+	int revision;
 };
 
 /*
@@ -1300,9 +1301,7 @@ static int sgtl5000_replace_vddd_with_ldo(struct snd_soc_codec *codec)
 
 static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
 {
-	int reg;
 	int ret;
-	int rev;
 	int i;
 	int external_vddd = 0;
 	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
@@ -1332,14 +1331,7 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
 	 * workaround for revision 0x11 and later,
 	 * roll back to use internal LDO
 	 */
-
-	ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg);
-	if (ret)
-		goto err_regulator_disable;
-
-	rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
-
-	if (external_vddd && rev >= 0x11) {
+	if (external_vddd && sgtl5000->revision >= 0x11) {
 		/* disable all regulator first */
 		regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
 					sgtl5000->supplies);
@@ -1362,9 +1354,6 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
 
 	return 0;
 
-err_regulator_disable:
-	regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
-				sgtl5000->supplies);
 err_regulator_free:
 	regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
 				sgtl5000->supplies);
@@ -1566,6 +1555,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
 
 	rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
 	dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev);
+	sgtl5000->revision = rev;
 
 	i2c_set_clientdata(client, sgtl5000);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-12-18 18:52 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-13  6:43 [PATCH 1/2] ASoC: sgtl5000: read chip revision for once Shawn Guo
2013-12-13  6:43 ` [PATCH 2/2] ASoC: sgtl5000: clean up sgtl5000_enable_regulators() Shawn Guo
2013-12-13 10:29   ` Li.Xiubo
2013-12-13 12:51     ` Shawn Guo
2013-12-16  3:31       ` Li.Xiubo
2013-12-16 11:29         ` Shawn Guo
2013-12-17  1:52           ` Li.Xiubo
2013-12-17  1:59           ` Mark Brown
2013-12-17  2:16             ` Shawn Guo
2013-12-17 11:37               ` Mark Brown
2013-12-17 12:39                 ` Shawn Guo
2013-12-17 12:46                   ` Mark Brown
2013-12-17 13:16                     ` Shawn Guo
2013-12-17 13:48                       ` Mark Brown
2013-12-17 13:58   ` Shawn Guo
     [not found]   ` <20131217134342.GP6691@S2101-09.ap.freescale.net>
2013-12-18  1:42     ` Li.Xiubo
2013-12-18 18:52   ` Mark Brown
2013-12-16 20:15 ` [PATCH 1/2] ASoC: sgtl5000: read chip revision for once Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).