aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-03-11 02:36:19 -0400
committerAnton Vorontsov <anton@enomsg.org>2013-04-01 02:24:37 -0400
commitf11d018fd6f24e611e06d6aedd91c59831b3bf05 (patch)
tree7f189b5dbf48b08f678803c76b5539b7a6f6fede /drivers/power
parent594f8f888d325591851f419c22e0349263214eff (diff)
wm831x_backup: 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>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/wm831x_backup.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/power/wm831x_backup.c b/drivers/power/wm831x_backup.c
index d9cc169f1424..58cbb009b74f 100644
--- a/drivers/power/wm831x_backup.c
+++ b/drivers/power/wm831x_backup.c
@@ -169,7 +169,8 @@ static int wm831x_backup_probe(struct platform_device *pdev)
169 struct power_supply *backup; 169 struct power_supply *backup;
170 int ret; 170 int ret;
171 171
172 devdata = kzalloc(sizeof(struct wm831x_backup), GFP_KERNEL); 172 devdata = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_backup),
173 GFP_KERNEL);
173 if (devdata == NULL) 174 if (devdata == NULL)
174 return -ENOMEM; 175 return -ENOMEM;
175 176
@@ -197,14 +198,8 @@ static int wm831x_backup_probe(struct platform_device *pdev)
197 backup->num_properties = ARRAY_SIZE(wm831x_backup_props); 198 backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
198 backup->get_property = wm831x_backup_get_prop; 199 backup->get_property = wm831x_backup_get_prop;
199 ret = power_supply_register(&pdev->dev, backup); 200 ret = power_supply_register(&pdev->dev, backup);
200 if (ret)
201 goto err_kmalloc;
202 201
203 return ret; 202 return ret;
204
205err_kmalloc:
206 kfree(devdata);
207 return ret;
208} 203}
209 204
210static int wm831x_backup_remove(struct platform_device *pdev) 205static int wm831x_backup_remove(struct platform_device *pdev)
@@ -213,7 +208,6 @@ static int wm831x_backup_remove(struct platform_device *pdev)
213 208
214 power_supply_unregister(&devdata->backup); 209 power_supply_unregister(&devdata->backup);
215 kfree(devdata->backup.name); 210 kfree(devdata->backup.name);
216 kfree(devdata);
217 211
218 return 0; 212 return 0;
219} 213}