Commit 6297b5e5 authored by Devendra Naga's avatar Devendra Naga Committed by Anton Vorontsov

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: default avatarDevendra Naga <develkernel412222@gmail.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent f7760995
...@@ -362,7 +362,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) ...@@ -362,7 +362,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy = kzalloc(sizeof(*psy), GFP_KERNEL); psy = kzalloc(sizeof(*psy), GFP_KERNEL);
if (!psy) if (!psy)
goto err_mem; return -ENOMEM;
pchg->psy = psy; pchg->psy = psy;
...@@ -375,7 +375,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) ...@@ -375,7 +375,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to); psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(pchg->dev, &psy->ac)) if (power_supply_register(pchg->dev, &psy->ac))
goto err_psy; goto err_psy_ac;
psy->usb.name = "usb"; psy->usb.name = "usb";
psy->usb.type = POWER_SUPPLY_TYPE_USB; psy->usb.type = POWER_SUPPLY_TYPE_USB;
...@@ -386,7 +386,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) ...@@ -386,7 +386,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to); psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(pchg->dev, &psy->usb)) if (power_supply_register(pchg->dev, &psy->usb))
goto err_psy; goto err_psy_usb;
psy->batt.name = "main_batt"; psy->batt.name = "main_batt";
psy->batt.type = POWER_SUPPLY_TYPE_BATTERY; psy->batt.type = POWER_SUPPLY_TYPE_BATTERY;
...@@ -396,13 +396,15 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) ...@@ -396,13 +396,15 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy->batt.external_power_changed = lp8727_charger_changed; psy->batt.external_power_changed = lp8727_charger_changed;
if (power_supply_register(pchg->dev, &psy->batt)) if (power_supply_register(pchg->dev, &psy->batt))
goto err_psy; goto err_psy_batt;
return 0; return 0;
err_mem: err_psy_batt:
return -ENOMEM; power_supply_unregister(&psy->usb);
err_psy: err_psy_usb:
power_supply_unregister(&psy->ac);
err_psy_ac:
kfree(psy); kfree(psy);
return -EPERM; return -EPERM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment