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>
This commit is contained in:
parent
74727c5715
commit
fb9adc5190
|
@ -442,35 +442,33 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
|
|||
ret = lp8727_init_device(pchg);
|
||||
if (ret) {
|
||||
dev_err(pchg->dev, "i2c communication err: %d", ret);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = lp8727_intr_config(pchg);
|
||||
if (ret) {
|
||||
dev_err(pchg->dev, "irq handler err: %d", ret);
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = lp8727_register_psy(pchg);
|
||||
if (ret) {
|
||||
dev_err(pchg->dev, "power supplies register err: %d", ret);
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = lp8727_intr_config(pchg);
|
||||
if (ret) {
|
||||
dev_err(pchg->dev, "irq handler err: %d", ret);
|
||||
lp8727_unregister_psy(pchg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit lp8727_remove(struct i2c_client *cl)
|
||||
{
|
||||
struct lp8727_chg *pchg = i2c_get_clientdata(cl);
|
||||
|
||||
lp8727_unregister_psy(pchg);
|
||||
free_irq(pchg->client->irq, pchg);
|
||||
flush_workqueue(pchg->irqthread);
|
||||
destroy_workqueue(pchg->irqthread);
|
||||
lp8727_unregister_psy(pchg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue