All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>
Cc: Manuel Lauss <manuel.lauss@gmail.com>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 5/7] ASoC: wm9705: Use core AC'97 reset helper
Date: Tue, 21 Jul 2015 21:53:04 +0200	[thread overview]
Message-ID: <1437508386-13828-6-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1437508386-13828-1-git-send-email-lars@metafoo.de>

Use the new snd_ac97_reset() helper and the reset functionality provided by
snd_soc_new_ac97_codec() to perform the device reset rather than
open-coding it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/wm9705.c | 40 ++++++++--------------------------------
 1 file changed, 8 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 5cc457e..744842c 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -22,6 +22,9 @@
 
 #include "wm9705.h"
 
+#define WM9705_VENDOR_ID 0x574d4c05
+#define WM9705_VENDOR_ID_MASK 0xffffffff
+
 /*
  * WM9705 register cache
  */
@@ -293,21 +296,6 @@ static struct snd_soc_dai_driver wm9705_dai[] = {
 	}
 };
 
-static int wm9705_reset(struct snd_soc_codec *codec)
-{
-	struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
-
-	if (soc_ac97_ops->reset) {
-		soc_ac97_ops->reset(ac97);
-		if (ac97_read(codec, 0) == wm9705_reg[0])
-			return 0; /* Success */
-	}
-
-	dev_err(codec->dev, "Failed to reset: AC97 link error\n");
-
-	return -EIO;
-}
-
 #ifdef CONFIG_PM
 static int wm9705_soc_suspend(struct snd_soc_codec *codec)
 {
@@ -324,7 +312,8 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
 	int i, ret;
 	u16 *cache = codec->reg_cache;
 
-	ret = wm9705_reset(codec);
+	ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID,
+		WM9705_VENDOR_ID_MASK);
 	if (ret < 0)
 		return ret;
 
@@ -342,30 +331,17 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
 static int wm9705_soc_probe(struct snd_soc_codec *codec)
 {
 	struct snd_ac97 *ac97;
-	int ret = 0;
 
-	ac97 = snd_soc_alloc_ac97_codec(codec);
+	ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
+		WM9705_VENDOR_ID_MASK);
 	if (IS_ERR(ac97)) {
-		ret = PTR_ERR(ac97);
 		dev_err(codec->dev, "Failed to register AC97 codec\n");
-		return ret;
+		return PTR_ERR(ac97);
 	}
 
-	ret = wm9705_reset(codec);
-	if (ret)
-		goto err_put_device;
-
-	ret = device_add(&ac97->dev);
-	if (ret)
-		goto err_put_device;
-
 	snd_soc_codec_set_drvdata(codec, ac97);
 
 	return 0;
-
-err_put_device:
-	put_device(&ac97->dev);
-	return ret;
 }
 
 static int wm9705_soc_remove(struct snd_soc_codec *codec)
-- 
2.1.4

  parent reply	other threads:[~2015-07-21 19:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 19:52 [PATCH 0/7] ASoC: Cleanup AC'97 reset handling Lars-Peter Clausen
2015-07-21 19:53 ` [PATCH 1/7] ALSA: ac97: Add helper function to reset the AC97 device Lars-Peter Clausen
2015-07-22  8:44   ` Takashi Iwai
2015-07-23 16:34   ` Applied "ALSA: ac97: Add helper function to reset the AC97 device" to the asoc tree Mark Brown
2015-07-21 19:53 ` [PATCH 2/7] ASoC: ac97: Add support for resetting device before registration Lars-Peter Clausen
2015-07-23 16:34   ` Applied "ASoC: ac97: Add support for resetting device before registration" to the asoc tree Mark Brown
2015-07-21 19:53 ` [PATCH 3/7] ASoC: ad1980: Use core AC'97 reset helper Lars-Peter Clausen
2015-07-23 16:34   ` Applied "ASoC: ad1980: Use core AC'97 reset helper" to the asoc tree Mark Brown
2015-07-21 19:53 ` [PATCH 4/7] ASoC: stac9766: Use core reset helper Lars-Peter Clausen
2015-07-23 16:34   ` Applied "ASoC: stac9766: Use core reset helper" to the asoc tree Mark Brown
2015-07-21 19:53 ` Lars-Peter Clausen [this message]
2015-07-23 16:34   ` Applied "ASoC: wm9705: Use core AC'97 " Mark Brown
2015-07-27 19:58   ` [PATCH 5/7] ASoC: wm9705: Use core AC'97 reset helper Charles Keepax
2015-07-21 19:53 ` [PATCH 6/7] ASoC: wm9712: " Lars-Peter Clausen
2015-07-23 16:34   ` Applied "ASoC: wm9712: Use core AC'97 reset helper" to the asoc tree Mark Brown
2015-07-27 19:59   ` [PATCH 6/7] ASoC: wm9712: Use core AC'97 reset helper Charles Keepax
2015-07-21 19:53 ` [PATCH 7/7] ASoC: wm9713: " Lars-Peter Clausen
2015-07-22  8:46   ` Takashi Iwai
2015-07-23 16:34   ` Applied "ASoC: wm9713: Use core AC'97 reset helper" to the asoc tree Mark Brown
2015-07-27 20:01   ` [PATCH 7/7] ASoC: wm9713: Use core AC'97 reset helper Charles Keepax
2015-07-22  8:48 ` [PATCH 0/7] ASoC: Cleanup AC'97 reset handling Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437508386-13828-6-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=lgirdwood@gmail.com \
    --cc=manuel.lauss@gmail.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.