summaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-11-23 11:03:19 -0800
committerMatthew Garrett <matthew.garrett@nebula.com>2014-01-21 08:44:03 -0500
commitcf508f4496f7dc7c162a8ac4440165d466f68d4b (patch)
tree45d67cca763cf5635ada1c5ad3d90ebe111d96d4 /drivers/platform
parent7da8fb27eff04e7283d24b0e483c300c8b1a9f5c (diff)
downloadtalos-obmc-linux-cf508f4496f7dc7c162a8ac4440165d466f68d4b.tar.gz
talos-obmc-linux-cf508f4496f7dc7c162a8ac4440165d466f68d4b.zip
compal-laptop: Use devm_kzalloc to allocate local data structure
Reduce code size and simplify error path. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/compal-laptop.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index eaa78edb1f4e..7155d79d6b3a 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -1026,24 +1026,21 @@ static int compal_probe(struct platform_device *pdev)
return 0;
/* Fan control */
- data = kzalloc(sizeof(struct compal_data), GFP_KERNEL);
+ data = devm_kzalloc(&pdev->dev, sizeof(struct compal_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
initialize_fan_control_data(data);
err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group);
- if (err) {
- kfree(data);
+ if (err)
return err;
- }
data->hwmon_dev = hwmon_device_register(&pdev->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
sysfs_remove_group(&pdev->dev.kobj,
&compal_attribute_group);
- kfree(data);
return err;
}
@@ -1083,8 +1080,6 @@ static int compal_remove(struct platform_device *pdev)
hwmon_device_unregister(data->hwmon_dev);
power_supply_unregister(&data->psy);
- kfree(data);
-
sysfs_remove_group(&pdev->dev.kobj, &compal_attribute_group);
return 0;
OpenPOWER on IntegriCloud