Commit e35115a5 authored by Liam Girdwood's avatar Liam Girdwood Committed by Jaroslav Kysela

[ALSA] ASoC codec error reporting

This patch improves the codec probe() error reporting by printing error
messages when the card or pcms fail to register.
Signed-off-by: default avatarLiam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 877b866d
...@@ -696,8 +696,8 @@ static int wm8731_init(struct snd_soc_device *socdev) ...@@ -696,8 +696,8 @@ static int wm8731_init(struct snd_soc_device *socdev)
/* register pcms */ /* register pcms */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
if (ret < 0) { if (ret < 0) {
kfree(codec->reg_cache); printk(KERN_ERR "wm8731: failed to create pcms\n");
return ret; goto pcm_err;
} }
/* power on device */ /* power on device */
...@@ -717,11 +717,18 @@ static int wm8731_init(struct snd_soc_device *socdev) ...@@ -717,11 +717,18 @@ static int wm8731_init(struct snd_soc_device *socdev)
wm8731_add_widgets(codec); wm8731_add_widgets(codec);
ret = snd_soc_register_card(socdev); ret = snd_soc_register_card(socdev);
if (ret < 0) { if (ret < 0) {
snd_soc_free_pcms(socdev); printk(KERN_ERR "wm8731: failed to register card\n");
snd_soc_dapm_free(socdev); goto card_err;
} }
return ret; return ret;
card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);
return ret;
} }
static struct snd_soc_device *wm8731_socdev; static struct snd_soc_device *wm8731_socdev;
......
...@@ -1075,8 +1075,8 @@ static int wm8750_init(struct snd_soc_device *socdev) ...@@ -1075,8 +1075,8 @@ static int wm8750_init(struct snd_soc_device *socdev)
/* register pcms */ /* register pcms */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
if (ret < 0) { if (ret < 0) {
kfree(codec->reg_cache); printk(KERN_ERR "wm8750: failed to create pcms\n");
return ret; goto pcm_err;
} }
/* charge output caps */ /* charge output caps */
...@@ -1106,10 +1106,16 @@ static int wm8750_init(struct snd_soc_device *socdev) ...@@ -1106,10 +1106,16 @@ static int wm8750_init(struct snd_soc_device *socdev)
wm8750_add_widgets(codec); wm8750_add_widgets(codec);
ret = snd_soc_register_card(socdev); ret = snd_soc_register_card(socdev);
if (ret < 0) { if (ret < 0) {
snd_soc_free_pcms(socdev); printk(KERN_ERR "wm8750: failed to register card\n");
snd_soc_dapm_free(socdev); goto card_err;
} }
return ret;
card_err:
snd_soc_free_pcms(socdev);
snd_soc_dapm_free(socdev);
pcm_err:
kfree(codec->reg_cache);
return ret; return ret;
} }
......
...@@ -692,10 +692,8 @@ static int wm9712_soc_probe(struct platform_device *pdev) ...@@ -692,10 +692,8 @@ static int wm9712_soc_probe(struct platform_device *pdev)
codec->reg_cache = codec->reg_cache =
kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL); kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL);
if (codec->reg_cache == NULL) { if (codec->reg_cache == NULL) {
kfree(codec->ac97); ret = -ENOMEM;
kfree(socdev->codec); goto cache_err;
socdev->codec = NULL;
return -ENOMEM;
} }
memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg)); memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg));
codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg); codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg);
...@@ -712,8 +710,10 @@ static int wm9712_soc_probe(struct platform_device *pdev) ...@@ -712,8 +710,10 @@ static int wm9712_soc_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&codec->dapm_paths); INIT_LIST_HEAD(&codec->dapm_paths);
ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
if (ret < 0) if (ret < 0) {
goto err; printk(KERN_ERR "wm9712: failed to register AC97 codec\n");
goto codec_err;
}
/* register pcms */ /* register pcms */
ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
...@@ -733,8 +733,10 @@ static int wm9712_soc_probe(struct platform_device *pdev) ...@@ -733,8 +733,10 @@ static int wm9712_soc_probe(struct platform_device *pdev)
wm9712_add_controls(codec); wm9712_add_controls(codec);
wm9712_add_widgets(codec); wm9712_add_widgets(codec);
ret = snd_soc_register_card(socdev); ret = snd_soc_register_card(socdev);
if (ret < 0) if (ret < 0) {
printk(KERN_ERR "wm9712: failed to register card\n");
goto reset_err; goto reset_err;
}
return 0; return 0;
...@@ -744,8 +746,10 @@ reset_err: ...@@ -744,8 +746,10 @@ reset_err:
pcm_err: pcm_err:
snd_soc_free_ac97_codec(codec); snd_soc_free_ac97_codec(codec);
err: codec_err:
kfree(socdev->codec->reg_cache); kfree(codec->reg_cache);
cache_err:
kfree(socdev->codec); kfree(socdev->codec);
socdev->codec = NULL; socdev->codec = NULL;
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