diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2012-08-31 05:22:46 -0400 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-09-20 20:51:57 -0400 |
commit | 74727c571517692ae24d0562676f2c61a86b9090 (patch) | |
tree | 2ea3c3f542081c3e373413b22f2eb8a592a820a3 /drivers/power/lp8727_charger.c | |
parent | a2778b0fe15d7adfe65b092ae842510c6c031370 (diff) |
lp8727_charger: Use devm_kzalloc()
Use devm_kzalloc() rather than kzalloc()/kfree() to make
allocating/freeing the private data simpler.
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.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c index 5c56d7e46993..0d3cb1de2eb1 100644 --- a/drivers/power/lp8727_charger.c +++ b/drivers/power/lp8727_charger.c | |||
@@ -360,7 +360,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg) | |||
360 | { | 360 | { |
361 | struct lp8727_psy *psy; | 361 | struct lp8727_psy *psy; |
362 | 362 | ||
363 | psy = kzalloc(sizeof(*psy), GFP_KERNEL); | 363 | psy = devm_kzalloc(pchg->dev, sizeof(*psy), GFP_KERNEL); |
364 | if (!psy) | 364 | if (!psy) |
365 | return -ENOMEM; | 365 | return -ENOMEM; |
366 | 366 | ||
@@ -405,7 +405,6 @@ err_psy_batt: | |||
405 | err_psy_usb: | 405 | err_psy_usb: |
406 | power_supply_unregister(&psy->ac); | 406 | power_supply_unregister(&psy->ac); |
407 | err_psy_ac: | 407 | err_psy_ac: |
408 | kfree(psy); | ||
409 | return -EPERM; | 408 | return -EPERM; |
410 | } | 409 | } |
411 | 410 | ||
@@ -419,7 +418,6 @@ static void lp8727_unregister_psy(struct lp8727_chg *pchg) | |||
419 | power_supply_unregister(&psy->ac); | 418 | power_supply_unregister(&psy->ac); |
420 | power_supply_unregister(&psy->usb); | 419 | power_supply_unregister(&psy->usb); |
421 | power_supply_unregister(&psy->batt); | 420 | power_supply_unregister(&psy->batt); |
422 | kfree(psy); | ||
423 | } | 421 | } |
424 | 422 | ||
425 | static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 423 | static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
@@ -430,7 +428,7 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
430 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 428 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
431 | return -EIO; | 429 | return -EIO; |
432 | 430 | ||
433 | pchg = kzalloc(sizeof(*pchg), GFP_KERNEL); | 431 | pchg = devm_kzalloc(&cl->dev, sizeof(*pchg), GFP_KERNEL); |
434 | if (!pchg) | 432 | if (!pchg) |
435 | return -ENOMEM; | 433 | return -ENOMEM; |
436 | 434 | ||
@@ -462,7 +460,6 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
462 | return 0; | 460 | return 0; |
463 | 461 | ||
464 | error: | 462 | error: |
465 | kfree(pchg); | ||
466 | return ret; | 463 | return ret; |
467 | } | 464 | } |
468 | 465 | ||
@@ -474,7 +471,6 @@ static int __devexit lp8727_remove(struct i2c_client *cl) | |||
474 | free_irq(pchg->client->irq, pchg); | 471 | free_irq(pchg->client->irq, pchg); |
475 | flush_workqueue(pchg->irqthread); | 472 | flush_workqueue(pchg->irqthread); |
476 | destroy_workqueue(pchg->irqthread); | 473 | destroy_workqueue(pchg->irqthread); |
477 | kfree(pchg); | ||
478 | return 0; | 474 | return 0; |
479 | } | 475 | } |
480 | 476 | ||