linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Linus Walleij <linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
Cc: Ben Dooks <ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 2/2] i2c: stu300: use devm allocation
Date: Mon, 9 Jul 2012 14:20:56 +0200	[thread overview]
Message-ID: <20120709122056.GI1296@pengutronix.de> (raw)
In-Reply-To: <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

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

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      parent reply	other threads:[~2012-07-09 12:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-12 17:33 [PATCH 2/2] i2c: stu300: use devm allocation Linus Walleij
     [not found] ` <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
2012-07-09 12:20   ` Wolfram Sang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120709122056.GI1296@pengutronix.de \
    --to=w.sang-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).