rx51_battery: Use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Mon, 11 Mar 2013 06:35:58 +0000 (15:35 +0900)
committerAnton Vorontsov <anton@enomsg.org>
Mon, 1 Apr 2013 06:25:30 +0000 (23:25 -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/rx51_battery.c

index 8208888b844e973004ba2a146cb40bf70c1458b5..f9dc9ffd5f97bcfad56b4fafade53bef2019734b 100644 (file)
@@ -202,7 +202,7 @@ static int rx51_battery_probe(struct platform_device *pdev)
        struct rx51_device_info *di;
        int ret;
 
-       di = kzalloc(sizeof(*di), GFP_KERNEL);
+       di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL);
        if (!di)
                return -ENOMEM;
 
@@ -217,7 +217,6 @@ static int rx51_battery_probe(struct platform_device *pdev)
        ret = power_supply_register(di->dev, &di->bat);
        if (ret) {
                platform_set_drvdata(pdev, NULL);
-               kfree(di);
                return ret;
        }
 
@@ -230,7 +229,6 @@ static int rx51_battery_remove(struct platform_device *pdev)
 
        power_supply_unregister(&di->bat);
        platform_set_drvdata(pdev, NULL);
-       kfree(di);
 
        return 0;
 }