Skip to content

Commit

Permalink
wm831x_backup: 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 594f8f8 commit f11d018
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/power/wm831x_backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ static int wm831x_backup_probe(struct platform_device *pdev)
struct power_supply *backup;
int ret;

devdata = kzalloc(sizeof(struct wm831x_backup), GFP_KERNEL);
devdata = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_backup),
GFP_KERNEL);
if (devdata == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -197,14 +198,8 @@ static int wm831x_backup_probe(struct platform_device *pdev)
backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
backup->get_property = wm831x_backup_get_prop;
ret = power_supply_register(&pdev->dev, backup);
if (ret)
goto err_kmalloc;

return ret;

err_kmalloc:
kfree(devdata);
return ret;
}

static int wm831x_backup_remove(struct platform_device *pdev)
Expand All @@ -213,7 +208,6 @@ static int wm831x_backup_remove(struct platform_device *pdev)

power_supply_unregister(&devdata->backup);
kfree(devdata->backup.name);
kfree(devdata);

return 0;
}
Expand Down

0 comments on commit f11d018

Please sign in to comment.