ASoC: remove a card from the list, if instantiation failed
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Thu, 18 Mar 2010 07:23:33 +0000 (08:23 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 19 Mar 2010 19:39:18 +0000 (19:39 +0000)
If instantiation of a card failed, we still have to remove it from the
card list on unregistration. This fixes an Oops on Migo-R, triggering,
when after a failed firmware load attempt the driver modules are removed
and re-inserted again.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/soc-core.c

index eb73aab78b94f3659a8ae427d7b156594f98f1e4..1ff553bbc0639acefa63c7995a7e52dd6f0e7050 100644 (file)
@@ -1283,26 +1283,25 @@ static int soc_remove(struct platform_device *pdev)
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
 
-       if (!card->instantiated)
-               return 0;
+       if (card->instantiated) {
+               run_delayed_work(&card->delayed_work);
 
-       run_delayed_work(&card->delayed_work);
+               if (platform->remove)
+                       platform->remove(pdev);
 
-       if (platform->remove)
-               platform->remove(pdev);
+               if (codec_dev->remove)
+                       codec_dev->remove(pdev);
 
-       if (codec_dev->remove)
-               codec_dev->remove(pdev);
+               for (i = 0; i < card->num_links; i++) {
+                       struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
+                       if (cpu_dai->remove)
+                               cpu_dai->remove(pdev, cpu_dai);
+               }
 
-       for (i = 0; i < card->num_links; i++) {
-               struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
-               if (cpu_dai->remove)
-                       cpu_dai->remove(pdev, cpu_dai);
+               if (card->remove)
+                       card->remove(pdev);
        }
 
-       if (card->remove)
-               card->remove(pdev);
-
        snd_soc_unregister_card(card);
 
        return 0;