[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1343643946-12815-1-git-send-email-develkernel412222@gmail.com>
Date: Mon, 30 Jul 2012 16:10:46 +0545
From: Devendra Naga <develkernel412222@...il.com>
To: Anton Vorontsov <cbou@...l.ru>,
David Woodhouse <dwmw2@...radead.org>,
ramakrishna.pallala@...el.com, linux-kernel@...r.kernel.org
Cc: Devendra Naga <develkernel412222@...il.com>
Subject: [PATCH V2 2/2] 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@...il.com>
---
Changes since V2:
* fix the comments from the Ramakrishna (ramakrishna.pallala@...el.com)
quoting his comments:
> if (power_supply_register(pchg->dev, &psy->usb))
> - goto err_psy;
> + goto err_psy_ac;
"err_psy_ac" label name is confusing. Why can't you use err_psy_usb
> if (power_supply_register(pchg->dev, &psy->batt))
> - goto err_psy;
> + goto err_psy_usb;
Same here, why don't you use err_psy_batt
drivers/power/lp8727_charger.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 6c0e0f9..8fb1c0f 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;
@@ -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,12 +396,14 @@ 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_batt:
+ power_supply_unregister(&psy->usb);
+err_psy_usb:
+ power_supply_unregister(&psy->ac);
err_psy:
kfree(psy);
return -EPERM;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists