Skip to content

Commit

Permalink
max8998_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 c09dd7d commit acfbf47
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/power/max8998_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ static int max8998_battery_probe(struct platform_device *pdev)
return -ENODEV;
}

max8998 = kzalloc(sizeof(struct max8998_battery_data), GFP_KERNEL);
max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_battery_data),
GFP_KERNEL);
if (!max8998)
return -ENOMEM;

Expand Down Expand Up @@ -174,7 +175,6 @@ static int max8998_battery_probe(struct platform_device *pdev)

return 0;
err:
kfree(max8998);
return ret;
}

Expand All @@ -183,7 +183,6 @@ static int max8998_battery_remove(struct platform_device *pdev)
struct max8998_battery_data *max8998 = platform_get_drvdata(pdev);

power_supply_unregister(&max8998->battery);
kfree(max8998);

return 0;
}
Expand Down

0 comments on commit acfbf47

Please sign in to comment.