Browse Source

[ALSA] Fix lockdep warning in ASoC machine probe

Don't take the codec mutex during machine probe until we have registered
with ALSA, fixing a lockdep warning reported by Dmitry Baryshkov.
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mark Brown 17 years ago
parent
commit
08c8efe692
1 changed files with 5 additions and 2 deletions
  1. 5 2
      sound/soc/soc-core.c

+ 5 - 2
sound/soc/soc-core.c

@@ -1101,7 +1101,6 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
 	struct snd_soc_machine *machine = socdev->machine;
 	struct snd_soc_machine *machine = socdev->machine;
 	int ret = 0, i, ac97 = 0, err = 0;
 	int ret = 0, i, ac97 = 0, err = 0;
 
 
-	mutex_lock(&codec->mutex);
 	for(i = 0; i < machine->num_links; i++) {
 	for(i = 0; i < machine->num_links; i++) {
 		if (socdev->machine->dai_link[i].init) {
 		if (socdev->machine->dai_link[i].init) {
 			err = socdev->machine->dai_link[i].init(codec);
 			err = socdev->machine->dai_link[i].init(codec);
@@ -1127,12 +1126,14 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
 		goto out;
 		goto out;
 	}
 	}
 
 
+	mutex_lock(&codec->mutex);
 #ifdef CONFIG_SND_SOC_AC97_BUS
 #ifdef CONFIG_SND_SOC_AC97_BUS
 	if (ac97) {
 	if (ac97) {
 		ret = soc_ac97_dev_register(codec);
 		ret = soc_ac97_dev_register(codec);
 		if (ret < 0) {
 		if (ret < 0) {
 			printk(KERN_ERR "asoc: AC97 device register failed\n");
 			printk(KERN_ERR "asoc: AC97 device register failed\n");
 			snd_card_free(codec->card);
 			snd_card_free(codec->card);
+			mutex_unlock(&codec->mutex);
 			goto out;
 			goto out;
 		}
 		}
 	}
 	}
@@ -1145,8 +1146,10 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
 	err = device_create_file(socdev->dev, &dev_attr_codec_reg);
 	err = device_create_file(socdev->dev, &dev_attr_codec_reg);
 	if (err < 0)
 	if (err < 0)
 		printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");
 		printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n");
-out:
+
 	mutex_unlock(&codec->mutex);
 	mutex_unlock(&codec->mutex);
+
+out:
 	return ret;
 	return ret;
 }
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_card);
 EXPORT_SYMBOL_GPL(snd_soc_register_card);