soc: tegra: rt5639: balance regulator disabling
Vinayak Pane [Sat, 14 Dec 2013 02:28:25 +0000 (18:28 -0800)]
Regulator enable, disable is not balanced in case of probe failure.
Restoring the regulators after probe failure and also at remove.

Bug 1425501

Change-Id: Ie6b5e87f3ec9cd31fcf7fa86c3f45022581b9ea1
Signed-off-by: Vinayak Pane <vpane@nvidia.com>
Reviewed-on: http://git-master/r/345554
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

sound/soc/tegra/tegra_rt5639.c

index 393d86c..8f8bb30 100644 (file)
@@ -1485,6 +1485,23 @@ err_unregister_switch:
        tegra_asoc_switch_unregister(&tegra_rt5639_headset_switch);
 err_fini_utils:
 #endif
+       if (machine->digital_reg) {
+               regulator_disable(machine->digital_reg);
+               regulator_put(machine->digital_reg);
+       }
+       if (machine->analog_reg) {
+               regulator_disable(machine->analog_reg);
+               regulator_put(machine->analog_reg);
+       }
+       if (machine->spk_reg)
+               regulator_put(machine->spk_reg);
+       if (machine->dmic_reg)
+               regulator_put(machine->dmic_reg);
+       if (machine->codec_reg) {
+               regulator_disable(machine->digital_reg);
+               regulator_put(machine->codec_reg);
+       }
+
        tegra_asoc_utils_fini(&machine->util_data);
 err_free_machine:
        if (np)
@@ -1507,16 +1524,23 @@ static int tegra_rt5639_driver_remove(struct platform_device *pdev)
                                        1,
                                        &tegra_rt5639_hp_jack_gpio);
 
-       if (machine->digital_reg)
+       if (machine->digital_reg) {
+               regulator_disable(machine->digital_reg);
                regulator_put(machine->digital_reg);
-       if (machine->analog_reg)
+       }
+       if (machine->analog_reg) {
+               regulator_disable(machine->analog_reg);
                regulator_put(machine->analog_reg);
+       }
        if (machine->spk_reg)
                regulator_put(machine->spk_reg);
+
        if (machine->dmic_reg)
                regulator_put(machine->dmic_reg);
-       if (machine->codec_reg)
+       if (machine->codec_reg) {
+               regulator_disable(machine->codec_reg);
                regulator_put(machine->codec_reg);
+       }
 
        if (gpio_is_valid(pdata->gpio_ldo1_en)) {
                gpio_set_value(pdata->gpio_ldo1_en, 0);