asoc: aic326x machine: handle switch unregistration
Nikesh Oswal [Wed, 14 Mar 2012 12:12:56 +0000 (17:12 +0530)]
If switch registration is success and later card registration
fails then we must unregister the switch

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

sound/soc/tegra/tegra_aic326x.c

index 26c5f18..b64ab41 100644 (file)
@@ -884,7 +884,7 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
                        ret);
-               goto err_fini_utils;
+               goto err_switch_unregister;
        }
 
        if (!card->instantiated) {
@@ -896,6 +896,10 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
 
 err_unregister_card:
        snd_soc_unregister_card(card);
+err_switch_unregister:
+#ifdef CONFIG_SWITCH
+       switch_dev_unregister(&aic326x_wired_switch_dev);
+#endif
 err_fini_utils:
        tegra_asoc_utils_fini(&machine->util_data);
 err_free_machine: