Commit f8d71be5 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: wm97xx: Reset AC'97 device before registering it

The wm97xx touchscreen driver binds itself to the snd_ac97 device that gets
registered by the CODEC driver and expects that the device has already been
reset. Before commit 6794f709 ("ASoC: ac97: Drop delayed device
registration") the device was only registered after the probe function of
the CODEC driver had finished running, but starting with the mentioned
commit the device is registered as soon as snd_soc_new_ac97_codec() is
called. This causes the touchscreen driver to no longer work. Modify the
CODEC drivers to use snd_soc_alloc_ac97_codec() instead of
snd_soc_new_ac97_codec() and make sure that the AC'97 device is reset before
the snd_ac97 device gets registered.

Fixes: 6794f709 ("ASoC: ac97: Drop delayed device registration")
Reported-by: default avatarManuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Tested-by: default avatarManuel Lauss <manuel.lauss@gmail.com>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
parent 47e03941
...@@ -344,23 +344,27 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) ...@@ -344,23 +344,27 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
int ret = 0; int ret = 0;
ac97 = snd_soc_new_ac97_codec(codec); ac97 = snd_soc_alloc_ac97_codec(codec);
if (IS_ERR(ac97)) { if (IS_ERR(ac97)) {
ret = PTR_ERR(ac97); ret = PTR_ERR(ac97);
dev_err(codec->dev, "Failed to register AC97 codec\n"); dev_err(codec->dev, "Failed to register AC97 codec\n");
return ret; return ret;
} }
snd_soc_codec_set_drvdata(codec, ac97);
ret = wm9705_reset(codec); ret = wm9705_reset(codec);
if (ret) if (ret)
goto reset_err; goto err_put_device;
ret = device_add(&ac97->dev);
if (ret)
goto err_put_device;
snd_soc_codec_set_drvdata(codec, ac97);
return 0; return 0;
reset_err: err_put_device:
snd_soc_free_ac97_codec(ac97); put_device(&ac97->dev);
return ret; return ret;
} }
......
...@@ -666,7 +666,7 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) ...@@ -666,7 +666,7 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
int ret = 0; int ret = 0;
wm9712->ac97 = snd_soc_new_ac97_codec(codec); wm9712->ac97 = snd_soc_alloc_ac97_codec(codec);
if (IS_ERR(wm9712->ac97)) { if (IS_ERR(wm9712->ac97)) {
ret = PTR_ERR(wm9712->ac97); ret = PTR_ERR(wm9712->ac97);
dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
...@@ -675,15 +675,19 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) ...@@ -675,15 +675,19 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
ret = wm9712_reset(codec, 0); ret = wm9712_reset(codec, 0);
if (ret < 0) if (ret < 0)
goto reset_err; goto err_put_device;
ret = device_add(&wm9712->ac97->dev);
if (ret)
goto err_put_device;
/* set alc mux to none */ /* set alc mux to none */
ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
return 0; return 0;
reset_err: err_put_device:
snd_soc_free_ac97_codec(wm9712->ac97); put_device(&wm9712->ac97->dev);
return ret; return ret;
} }
......
...@@ -1225,7 +1225,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) ...@@ -1225,7 +1225,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
int ret = 0, reg; int ret = 0, reg;
wm9713->ac97 = snd_soc_new_ac97_codec(codec); wm9713->ac97 = snd_soc_alloc_ac97_codec(codec);
if (IS_ERR(wm9713->ac97)) if (IS_ERR(wm9713->ac97))
return PTR_ERR(wm9713->ac97); return PTR_ERR(wm9713->ac97);
...@@ -1234,7 +1234,11 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) ...@@ -1234,7 +1234,11 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
wm9713_reset(codec, 0); wm9713_reset(codec, 0);
ret = wm9713_reset(codec, 1); ret = wm9713_reset(codec, 1);
if (ret < 0) if (ret < 0)
goto reset_err; goto err_put_device;
ret = device_add(&wm9713->ac97->dev);
if (ret)
goto err_put_device;
/* unmute the adc - move to kcontrol */ /* unmute the adc - move to kcontrol */
reg = ac97_read(codec, AC97_CD) & 0x7fff; reg = ac97_read(codec, AC97_CD) & 0x7fff;
...@@ -1242,8 +1246,8 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) ...@@ -1242,8 +1246,8 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
return 0; return 0;
reset_err: err_put_device:
snd_soc_free_ac97_codec(wm9713->ac97); put_device(&wm9713->ac97->dev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment