return -EIO;
}
-- -static int wm9712_soc_suspend(struct snd_soc_codec *codec)
-- -{
-- - wm9712_set_bias_level(codec, SND_SOC_BIAS_OFF);
-- - return 0;
-- -}
-- -
static int wm9712_soc_resume(struct snd_soc_codec *codec)
{
+++ struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
int i, ret;
u16 *cache = codec->reg_cache;
static int wm9712_soc_probe(struct snd_soc_codec *codec)
{
+++ struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
int ret = 0;
--- ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
--- if (ret < 0) {
- - printk(KERN_ERR "wm9712: failed to register AC97 codec\n");
- dev_err(codec->dev, "Failed to register AC97 codec\n");
+++ wm9712->ac97 = snd_soc_new_ac97_codec(codec);
+++ if (IS_ERR(wm9712->ac97)) {
+++ ret = PTR_ERR(wm9712->ac97);
+++ dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
return ret;
}
/* set alc mux to none */
ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
-- - wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
- - snd_soc_add_codec_controls(codec, wm9712_snd_ac97_controls,
- - ARRAY_SIZE(wm9712_snd_ac97_controls));
-- -
return 0;
reset_err:
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0006,
0x0001, 0x0000, 0x574d, 0x4c13,
-- 0x0000, 0x0000, 0x0000
- 0x0000, 0x0000
};
---/* virtual HP mixers regs */
---#define HPL_MIXER 0x80
---#define HPR_MIXER 0x82
-- #define MICB_MUX 0x82
+++#define HPL_MIXER 0
+++#define HPR_MIXER 1
static const char *wm9713_mic_mixer[] = {"Stereo", "Mic 1", "Mic 2", "Mute"};
static const char *wm9713_rec_mux[] = {"Stereo", "Left", "Right", "Mute"};
return 1;
}
--- soc_ac97_ops->reset(codec->ac97);
+++ soc_ac97_ops->reset(wm9713->ac97);
if (soc_ac97_ops->warm_reset)
--- soc_ac97_ops->warm_reset(codec->ac97);
-- if (ac97_read(codec, 0) != wm9713_reg[0])
+++ soc_ac97_ops->warm_reset(wm9713->ac97);
++ if (ac97_read(codec, 0) != wm9713_reg[0]) {
++ dev_err(codec->dev, "Failed to reset: AC97 link error\n");
return -EIO;
++ }
++
return 0;
}
EXPORT_SYMBOL_GPL(wm9713_reset);
static int wm9713_soc_probe(struct snd_soc_codec *codec)
{
-- struct wm9713_priv *wm9713;
+++ struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
int ret = 0, reg;
-- wm9713 = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
-- if (wm9713 == NULL)
-- return -ENOMEM;
-- snd_soc_codec_set_drvdata(codec, wm9713);
--
--- ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
--- if (ret < 0)
-- goto codec_err;
- return ret;
+++ wm9713->ac97 = snd_soc_new_ac97_codec(codec);
+++ if (IS_ERR(wm9713->ac97))
+++ return PTR_ERR(wm9713->ac97);
/* do a cold reset for the controller and then try
* a warm reset followed by an optional cold reset for codec */
wm9713_reset(codec, 0);
ret = wm9713_reset(codec, 1);
-- if (ret < 0) {
-- printk(KERN_ERR "Failed to reset WM9713: AC97 link error\n");
++ if (ret < 0)
goto reset_err;
-- }
--
-- wm9713_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
- wm9713_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-
/* unmute the adc - move to kcontrol */
reg = ac97_read(codec, AC97_CD) & 0x7fff;
ac97_write(codec, AC97_CD, reg);
return 0;
reset_err:
--- snd_soc_free_ac97_codec(codec);
-- codec_err:
-- kfree(wm9713);
+++ snd_soc_free_ac97_codec(wm9713->ac97);
return ret;
}
static int wm9713_soc_remove(struct snd_soc_codec *codec)
{
- snd_soc_free_ac97_codec(codec);
+ struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
-- snd_soc_free_ac97_codec(codec);
-- kfree(wm9713);
+++
+++ snd_soc_free_ac97_codec(wm9713->ac97);
return 0;
}
static int wm9713_probe(struct platform_device *pdev)
{
++ struct wm9713_priv *wm9713;
++
++ wm9713 = devm_kzalloc(&pdev->dev, sizeof(*wm9713), GFP_KERNEL);
++ if (wm9713 == NULL)
++ return -ENOMEM;
++
+++ mutex_init(&wm9713->lock);
+++
++ platform_set_drvdata(pdev, wm9713);
++
return snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai));
}