asoc: tegra: aic326x machine: register the sw dev before the card
Nikesh Oswal [Wed, 8 Feb 2012 18:35:03 +0000 (10:35 -0800)]
If sw dev is registered after the card then there would be a kernel
panic if we try to boot the device with Headset connected because
when the card is registered init of every dai link is called from where
we register the jack with codec driver and doing so will enable headset
interrupts which would try to set switch state for an unregistered switch
device

Change-Id: Ie951f41028a3459e4e13d021c80c3f830bbcc533
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: http://git-master/r/84536
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/tegra/tegra_aic326x.c

index 80ef3ab..f9a9257 100644 (file)
@@ -1045,6 +1045,16 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
        tegra_aic326x_i2s_dai_name[machine->codec_info[BT_SCO].i2s_id];
 #endif
 
+#ifdef CONFIG_SWITCH
+       /* Add h2w switch class support */
+       ret = switch_dev_register(&aic326x_wired_switch_dev);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "not able to register switch device %d\n",
+                       ret);
+               goto err_fini_utils;
+       }
+#endif
+
        ret = snd_soc_register_card(card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
@@ -1057,16 +1067,6 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
                goto err_unregister_card;
        }
 
-#ifdef CONFIG_SWITCH
-       /* Add h2w switch class support */
-       ret = switch_dev_register(&aic326x_wired_switch_dev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "not able to register switch device %d\n",
-                       ret);
-               goto err_unregister_card;
-       }
-#endif
-
        return 0;
 
 err_unregister_card: