staging: media: omap1: Replace kzalloc with devm_kzalloc
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Tue, 22 Mar 2016 16:52:48 +0000 (22:22 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2016 14:30:36 +0000 (07:30 -0700)
Replace kzalloc with devm_kzalloc and consequently remove kfrees in
probe and remove functions of a platform device.

As a result of this change, remove unnecessary out of memory message
and an unnecessary label.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/omap1/omap1_camera.c

index bd001804ed470dbd276c97e27d03d2e21a5f16fc..8cc4a0a5a83511a4d78730ddfd85f1e70bb68172 100644 (file)
@@ -1580,11 +1580,10 @@ static int omap1_cam_probe(struct platform_device *pdev)
        if (IS_ERR(clk))
                return PTR_ERR(clk);
 
-       pcdev = kzalloc(sizeof(*pcdev) + resource_size(res), GFP_KERNEL);
-       if (!pcdev) {
-               dev_err(&pdev->dev, "Could not allocate pcdev\n");
+       pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev) + resource_size(res),
+                            GFP_KERNEL);
+       if (!pcdev)
                return -ENOMEM;
-       }
 
        pcdev->res = res;
        pcdev->clk = clk;
@@ -1620,10 +1619,8 @@ static int omap1_cam_probe(struct platform_device *pdev)
        /*
         * Request the region.
         */
-       if (!request_mem_region(res->start, resource_size(res), DRIVER_NAME)) {
-               err = -EBUSY;
-               goto exit_kfree;
-       }
+       if (!request_mem_region(res->start, resource_size(res), DRIVER_NAME))
+               return -EBUSY;
 
        base = ioremap(res->start, resource_size(res));
        if (!base) {
@@ -1680,8 +1677,6 @@ exit_iounmap:
        iounmap(base);
 exit_release:
        release_mem_region(res->start, resource_size(res));
-exit_kfree:
-       kfree(pcdev);
 exit:
        return err;
 }
@@ -1704,8 +1699,6 @@ static int omap1_cam_remove(struct platform_device *pdev)
        res = pcdev->res;
        release_mem_region(res->start, resource_size(res));
 
-       kfree(pcdev);
-
        dev_info(&pdev->dev, "OMAP1 Camera Interface driver unloaded\n");
 
        return 0;