Re: [PATCH 2/2] i2c: stu300: use devm allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 12, 2012 at 07:33:37PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@xxxxxxxxxx>
> 
> Allocate memory for device state using devm_kzalloc() to
> simplify accounting.
> 
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Please use devm_* for resource allocation, too, then...

> ---
>  drivers/i2c/busses/i2c-stu300.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
> index 79b7851..e5c10c5 100644
> --- a/drivers/i2c/busses/i2c-stu300.c
> +++ b/drivers/i2c/busses/i2c-stu300.c
> @@ -873,7 +873,7 @@ stu300_probe(struct platform_device *pdev)
>  	int ret = 0;
>  	char clk_name[] = "I2C0";
>  
> -	dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL);
> +	dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL);
>  	if (!dev) {
>  		dev_err(&pdev->dev, "could not allocate device struct\n");
>  		ret = -ENOMEM;
> @@ -971,7 +971,6 @@ stu300_probe(struct platform_device *pdev)
>   err_no_resource:
>  	clk_put(dev->clk);
>   err_no_clk:
> -	kfree(dev);
>   err_no_devmem:
>  	dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n",
>  		pdev->id);
> @@ -1020,7 +1019,6 @@ stu300_remove(struct platform_device *pdev)
>  	clk_unprepare(dev->clk);
>  	clk_put(dev->clk);
>  	platform_set_drvdata(pdev, NULL);
> -	kfree(dev);
>  	return 0;
>  }
>  
> -- 
> 1.7.9.2
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux