]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
wm831x_backup: Use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Mon, 11 Mar 2013 06:36:19 +0000 (15:36 +0900)
committerAnton Vorontsov <anton@enomsg.org>
Mon, 1 Apr 2013 06:24:37 +0000 (23:24 -0700)
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>
drivers/power/wm831x_backup.c

index d9cc169f1424d94624fb7fe24e41ef4be3657822..58cbb009b74f144564b069bf9344e801a5f02743 100644 (file)
@@ -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;
 
@@ -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)
@@ -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;
 }