aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/lp8727_charger.c
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-08-31 05:23:03 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-09-20 20:55:34 -0400
commitfb9adc5190d7605506ebc0e05351baa57365cc90 (patch)
tree4b84b79e2c0abc2de7a9513a3aaaa7f884effae3 /drivers/power/lp8727_charger.c
parent74727c571517692ae24d0562676f2c61a86b9090 (diff)
lp8727_charger: Cleanup _probe() and _remove()
If the lp8727_register_psy() gets failed, registered interrupt handler should be freed, but this is not complete solution. It has still problem. Assume that the IRQ occurs while unregistering power supply devices. Then the ISR will access to freed IRQ. From Anton's opinion, it can be resolved if re-ordering the call sequence. Register power supplies first, then create interrupt handler. Then no need to free the IRQ in _probe(). Additionally goto statements can be removed because those can be replaced with return statements. The _remove() should be changed the sequence - in reverse order of _probe() Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.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.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 0d3cb1de2eb1..b2df11458d98 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -442,35 +442,33 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
442 ret = lp8727_init_device(pchg); 442 ret = lp8727_init_device(pchg);
443 if (ret) { 443 if (ret) {
444 dev_err(pchg->dev, "i2c communication err: %d", ret); 444 dev_err(pchg->dev, "i2c communication err: %d", ret);
445 goto error; 445 return ret;
446 } 446 }
447 447
448 ret = lp8727_intr_config(pchg); 448 ret = lp8727_register_psy(pchg);
449 if (ret) { 449 if (ret) {
450 dev_err(pchg->dev, "irq handler err: %d", ret); 450 dev_err(pchg->dev, "power supplies register err: %d", ret);
451 goto error; 451 return ret;
452 } 452 }
453 453
454 ret = lp8727_register_psy(pchg); 454 ret = lp8727_intr_config(pchg);
455 if (ret) { 455 if (ret) {
456 dev_err(pchg->dev, "power supplies register err: %d", ret); 456 dev_err(pchg->dev, "irq handler err: %d", ret);
457 goto error; 457 lp8727_unregister_psy(pchg);
458 return ret;
458 } 459 }
459 460
460 return 0; 461 return 0;
461
462error:
463 return ret;
464} 462}
465 463
466static int __devexit lp8727_remove(struct i2c_client *cl) 464static int __devexit lp8727_remove(struct i2c_client *cl)
467{ 465{
468 struct lp8727_chg *pchg = i2c_get_clientdata(cl); 466 struct lp8727_chg *pchg = i2c_get_clientdata(cl);
469 467
470 lp8727_unregister_psy(pchg);
471 free_irq(pchg->client->irq, pchg); 468 free_irq(pchg->client->irq, pchg);
472 flush_workqueue(pchg->irqthread); 469 flush_workqueue(pchg->irqthread);
473 destroy_workqueue(pchg->irqthread); 470 destroy_workqueue(pchg->irqthread);
471 lp8727_unregister_psy(pchg);
474 return 0; 472 return 0;
475} 473}
476 474