Skip to content

Commit

Permalink
max8903_charger: Use devm_kzalloc()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jingoo Han authored and Anton Vorontsov committed Apr 1, 2013
1 parent d4a20f5 commit f3f66b3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/power/max8903_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static int max8903_probe(struct platform_device *pdev)
int ta_in = 0;
int usb_in = 0;

data = kzalloc(sizeof(struct max8903_data), GFP_KERNEL);
data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL);
if (data == NULL) {
dev_err(dev, "Cannot allocate memory.\n");
return -ENOMEM;
Expand Down Expand Up @@ -341,7 +341,6 @@ static int max8903_probe(struct platform_device *pdev)
err_psy:
power_supply_unregister(&data->psy);
err:
kfree(data);
return ret;
}

Expand All @@ -359,7 +358,6 @@ static int max8903_remove(struct platform_device *pdev)
if (pdata->dc_valid)
free_irq(gpio_to_irq(pdata->dok), data);
power_supply_unregister(&data->psy);
kfree(data);
}

return 0;
Expand Down

0 comments on commit f3f66b3

Please sign in to comment.