staging: most: hdm-dim2: Replace kzalloc with devm_kzalloc

Devm_ functions allocate memory that is released when a driver detaches.
Replace kzalloc with devm_kzalloc and remove corresponding
kfrees from probe and remove functions of a platform
device.

Also, an unnecessary label has been removed.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Amitoj Kaur Chawla 2016-02-18 20:11:36 +05:30 committed by Greg Kroah-Hartman
parent 11b49d9bb6
commit 8661fca6f6
1 changed files with 3 additions and 6 deletions

View File

@ -736,7 +736,7 @@ static int dim2_probe(struct platform_device *pdev)
int ret, i; int ret, i;
struct kobject *kobj; struct kobject *kobj;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
@ -750,13 +750,13 @@ static int dim2_probe(struct platform_device *pdev)
if (!res) { if (!res) {
pr_err("no memory region defined\n"); pr_err("no memory region defined\n");
ret = -ENOENT; ret = -ENOENT;
goto err_free_dev; return ret;
} }
if (!request_mem_region(res->start, resource_size(res), pdev->name)) { if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
pr_err("failed to request mem region\n"); pr_err("failed to request mem region\n");
ret = -EBUSY; ret = -EBUSY;
goto err_free_dev; return ret;
} }
dev->io_base = ioremap(res->start, resource_size(res)); dev->io_base = ioremap(res->start, resource_size(res));
@ -862,9 +862,7 @@ err_unmap_io:
iounmap(dev->io_base); iounmap(dev->io_base);
err_release_mem: err_release_mem:
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
err_free_dev:
#endif #endif
kfree(dev);
return ret; return ret;
} }
@ -897,7 +895,6 @@ static int dim2_remove(struct platform_device *pdev)
iounmap(dev->io_base); iounmap(dev->io_base);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
#endif #endif
kfree(dev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
/* /*