diff mbox

[v2,2/3] video: xilinxfb: Use devm_kzalloc instead of kzalloc

Message ID 748c16093663172918a90a53dc472cb8beb584ca.1381315928.git.michal.simek@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Simek Oct. 9, 2013, 10:52 a.m. UTC
Simplify driver probe and release function.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
---
Changes in v2:
Rebased on git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git for-next

 drivers/video/xilinxfb.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

--
1.8.2.3

Comments

Joe Perches Oct. 9, 2013, 3:13 p.m. UTC | #1
On Wed, 2013-10-09 at 12:52 +0200, Michal Simek wrote:
> Simplify driver probe and release function.
[]
> diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
[]
> @@ -423,7 +419,7 @@ static int xilinxfb_of_probe(struct platform_device *pdev)
>  	pdata = xilinx_fb_default_pdata;
> 
>  	/* Allocate the driver data region */
> -	drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
> +	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
>  	if (!drvdata) {
>  		dev_err(&pdev->dev, "Couldn't allocate device private record\n");

Be nice to remove the unnecessary OOM message.
There's already a generic dump_stack on OOM.


--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Simek Oct. 10, 2013, 6:24 a.m. UTC | #2
On 10/09/2013 05:13 PM, Joe Perches wrote:
> On Wed, 2013-10-09 at 12:52 +0200, Michal Simek wrote:
>> Simplify driver probe and release function.
> []
>> diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
> []
>> @@ -423,7 +419,7 @@ static int xilinxfb_of_probe(struct platform_device *pdev)
>>  	pdata = xilinx_fb_default_pdata;
>>
>>  	/* Allocate the driver data region */
>> -	drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
>> +	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
>>  	if (!drvdata) {
>>  		dev_err(&pdev->dev, "Couldn't allocate device private record\n");
> 
> Be nice to remove the unnecessary OOM message.
> There's already a generic dump_stack on OOM.

Ah yeah - this series was made before I knew this.
Will send v3.

Thanks,
Michal
diff mbox

Patch

diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index d12345f..98c7a6f 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -368,8 +368,6 @@  err_fbmem:
 		devm_iounmap(dev, drvdata->regs);

 err_region:
-	kfree(drvdata);
-
 	return rc;
 }

@@ -402,8 +400,6 @@  static int xilinxfb_release(struct device *dev)
 		dcr_unmap(drvdata->dcr_host, drvdata->dcr_len);
 #endif

-	kfree(drvdata);
-
 	return 0;
 }

@@ -423,7 +419,7 @@  static int xilinxfb_of_probe(struct platform_device *pdev)
 	pdata = xilinx_fb_default_pdata;

 	/* Allocate the driver data region */
-	drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata) {
 		dev_err(&pdev->dev, "Couldn't allocate device private record\n");
 		return -ENOMEM;
@@ -451,7 +447,6 @@  static int xilinxfb_of_probe(struct platform_device *pdev)
 		drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len);
 		if (!DCR_MAP_OK(drvdata->dcr_host)) {
 			dev_err(&op->dev, "invalid DCR address\n");
-			kfree(drvdata);
 			return -ENODEV;
 		}
 	}