diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-03-11 15:34:55 +0900 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-03-31 23:25:36 -0700 |
commit | d4a20f57d3407de31eb692ee57aaad81f15d4652 (patch) | |
tree | 2c5576c154edef371ccd02bb5db2d89cb3e307cf | |
parent | acfbf47a903a22d4679137ad04d00194baec6a0c (diff) | |
download | linux-stable-d4a20f57d3407de31eb692ee57aaad81f15d4652.tar.gz linux-stable-d4a20f57d3407de31eb692ee57aaad81f15d4652.tar.bz2 linux-stable-d4a20f57d3407de31eb692ee57aaad81f15d4652.zip |
max8997_charger: Use devm_kzalloc()
Use devm_kzalloc() to make cleanup paths more simple.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
-rw-r--r-- | drivers/power/max8997_charger.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/power/max8997_charger.c b/drivers/power/max8997_charger.c index e757885b620c..4bdedfed936d 100644 --- a/drivers/power/max8997_charger.c +++ b/drivers/power/max8997_charger.c @@ -138,7 +138,8 @@ static int max8997_battery_probe(struct platform_device *pdev) return ret; } - charger = kzalloc(sizeof(struct charger_data), GFP_KERNEL); + charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data), + GFP_KERNEL); if (charger == NULL) { dev_err(&pdev->dev, "Cannot allocate memory.\n"); return -ENOMEM; @@ -158,13 +159,10 @@ static int max8997_battery_probe(struct platform_device *pdev) ret = power_supply_register(&pdev->dev, &charger->battery); if (ret) { dev_err(&pdev->dev, "failed: power supply register\n"); - goto err; + return ret; } return 0; -err: - kfree(charger); - return ret; } static int max8997_battery_remove(struct platform_device *pdev) @@ -172,7 +170,6 @@ static int max8997_battery_remove(struct platform_device *pdev) struct charger_data *charger = platform_get_drvdata(pdev); power_supply_unregister(&charger->battery); - kfree(charger); return 0; } |