Commit cf508f44 authored by Guenter Roeck's avatar Guenter Roeck Committed by Matthew Garrett

compal-laptop: Use devm_kzalloc to allocate local data structure

Reduce code size and simplify error path.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
parent 7da8fb27
...@@ -1026,24 +1026,21 @@ static int compal_probe(struct platform_device *pdev) ...@@ -1026,24 +1026,21 @@ static int compal_probe(struct platform_device *pdev)
return 0; return 0;
/* Fan control */ /* Fan control */
data = kzalloc(sizeof(struct compal_data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(struct compal_data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
initialize_fan_control_data(data); initialize_fan_control_data(data);
err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group); err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group);
if (err) { if (err)
kfree(data);
return err; return err;
}
data->hwmon_dev = hwmon_device_register(&pdev->dev); data->hwmon_dev = hwmon_device_register(&pdev->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
sysfs_remove_group(&pdev->dev.kobj, sysfs_remove_group(&pdev->dev.kobj,
&compal_attribute_group); &compal_attribute_group);
kfree(data);
return err; return err;
} }
...@@ -1083,8 +1080,6 @@ static int compal_remove(struct platform_device *pdev) ...@@ -1083,8 +1080,6 @@ static int compal_remove(struct platform_device *pdev)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
power_supply_unregister(&data->psy); power_supply_unregister(&data->psy);
kfree(data);
sysfs_remove_group(&pdev->dev.kobj, &compal_attribute_group); sysfs_remove_group(&pdev->dev.kobj, &compal_attribute_group);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment