diff options
author | Devendra Naga <develkernel412222@gmail.com> | 2012-07-29 21:46:55 +0400 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-08-23 06:14:09 +0400 |
commit | 6297b5e54b5511d4e72e8d5fc3b139650adc74d8 (patch) | |
tree | 1180e16365478b00a4c9f26ff0c39297e16a789a /drivers/power/lp8727_charger.c | |
parent | f77609959ade7378eed8b03df4c248f6d44c7e15 (diff) | |
download | linux-6297b5e54b5511d4e72e8d5fc3b139650adc74d8.tar.xz |
lp8727_charger: Unregister power supply at error path of lp8727_register_psy
if usb power supply registration fails,
we wont unregister the ac power supply
if battery power supply registration fails,
we wont unregister the usb, and ac supply,
take care of those things and also no need of goto -err_mem: at the fail case of
kzalloc simply can have return -ENOMEM
Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/lp8727_charger.c')
-rw-r--r-- | drivers/power/lp8727_charger.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c index 6a364f4798f7..4e37b269ac95 100644 --- a/drivers/power/lp8727_charger.c +++ b/drivers/power/lp8727_charger.c @@ -362,7 +362,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) psy = kzalloc(sizeof(*psy), GFP_KERNEL); if (!psy) - goto err_mem; + return -ENOMEM; pchg->psy = psy; @@ -375,7 +375,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to); if (power_supply_register(pchg->dev, &psy->ac)) - goto err_psy; + goto err_psy_ac; psy->usb.name = "usb"; psy->usb.type = POWER_SUPPLY_TYPE_USB; @@ -386,7 +386,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to); if (power_supply_register(pchg->dev, &psy->usb)) - goto err_psy; + goto err_psy_usb; psy->batt.name = "main_batt"; psy->batt.type = POWER_SUPPLY_TYPE_BATTERY; @@ -396,13 +396,15 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) psy->batt.external_power_changed = lp8727_charger_changed; if (power_supply_register(pchg->dev, &psy->batt)) - goto err_psy; + goto err_psy_batt; return 0; -err_mem: - return -ENOMEM; -err_psy: +err_psy_batt: + power_supply_unregister(&psy->usb); +err_psy_usb: + power_supply_unregister(&psy->ac); +err_psy_ac: kfree(psy); return -EPERM; } |