Skip to content

Commit

Permalink
ab8500_charger: Use devm_regulator_get API
Browse files Browse the repository at this point in the history
devm_regulator_get() is device managed and makes error handling and code
cleanup simpler.

Signed-off-by: Sachin Kamat <[email protected]>
Acked-by: Arun Murthy <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
  • Loading branch information
Sachin Kamat authored and enomsg committed Jan 6, 2013
1 parent bde83b9 commit 8feffd1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/power/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2604,9 +2604,6 @@ static int ab8500_charger_remove(struct platform_device *pdev)
free_irq(irq, di);
}

/* disable the regulator */
regulator_put(di->regu);

/* Backup battery voltage and current disable */
ret = abx500_mask_and_set_register_interruptible(di->dev,
AB8500_RTC, AB8500_RTC_CTRL_REG, RTC_BUP_CH_ENA, 0);
Expand Down Expand Up @@ -2759,7 +2756,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
* is a charger connected to avoid erroneous BTEMP_HIGH/LOW
* interrupts during charging
*/
di->regu = regulator_get(di->dev, "vddadc");
di->regu = devm_regulator_get(di->dev, "vddadc");
if (IS_ERR(di->regu)) {
ret = PTR_ERR(di->regu);
dev_err(di->dev, "failed to get vddadc regulator\n");
Expand All @@ -2771,14 +2768,14 @@ static int ab8500_charger_probe(struct platform_device *pdev)
ret = ab8500_charger_init_hw_registers(di);
if (ret) {
dev_err(di->dev, "failed to initialize ABB registers\n");
goto free_regulator;
goto free_charger_wq;
}

/* Register AC charger class */
ret = power_supply_register(di->dev, &di->ac_chg.psy);
if (ret) {
dev_err(di->dev, "failed to register AC charger\n");
goto free_regulator;
goto free_charger_wq;
}

/* Register USB charger class */
Expand Down Expand Up @@ -2852,8 +2849,6 @@ static int ab8500_charger_probe(struct platform_device *pdev)
power_supply_unregister(&di->usb_chg.psy);
free_ac:
power_supply_unregister(&di->ac_chg.psy);
free_regulator:
regulator_put(di->regu);
free_charger_wq:
destroy_workqueue(di->charger_wq);
return ret;
Expand Down

0 comments on commit 8feffd1

Please sign in to comment.