public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org,
	shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	brian-ZKiFAVwZFM2FeswfMrDH8w@public.gmane.org
Subject: Re: [PATCH 1/3] i2c: i2c-mux-gpio: Use devm_kzalloc instead of kzalloc
Date: Sat, 22 Sep 2012 15:09:05 +0200	[thread overview]
Message-ID: <20120922150905.643f7604@endymion.delvare> (raw)
In-Reply-To: <1348241535-27754-2-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

On Fri, 21 Sep 2012 17:32:12 +0200, Maxime Ripard wrote:
> Use the devm_kzalloc managed function to stripdown the error and remove
> code.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  drivers/i2c/muxes/i2c-mux-gpio.c |   14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
> index 68b1f8e..fbc400b 100644
> --- a/drivers/i2c/muxes/i2c-mux-gpio.c
> +++ b/drivers/i2c/muxes/i2c-mux-gpio.c
> @@ -71,7 +71,7 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	mux = kzalloc(sizeof(*mux), GFP_KERNEL);
> +	mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL);
>  	if (!mux) {
>  		ret = -ENOMEM;
>  		goto alloc_failed;
> @@ -79,11 +79,12 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
>  
>  	mux->parent = parent;
>  	mux->data = *pdata;
> -	mux->adap = kzalloc(sizeof(struct i2c_adapter *) * pdata->n_values,
> -			    GFP_KERNEL);
> +	mux->adap = devm_kzalloc(&pdev->dev,
> +				sizeof(struct i2c_adapter *) * pdata->n_values,
> +				GFP_KERNEL);

Alignment is off by one here.

>  	if (!mux->adap) {
>  		ret = -ENOMEM;
> -		goto alloc_failed2;
> +		goto alloc_failed;
>  	}
>  
>  	if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) {
> @@ -128,9 +129,6 @@ add_adapter_failed:
>  err_request_gpio:
>  	for (; i > 0; i--)
>  		gpio_free(pdata->gpios[i - 1]);
> -	kfree(mux->adap);
> -alloc_failed2:
> -	kfree(mux);
>  alloc_failed:
>  	i2c_put_adapter(parent);
>  
> @@ -150,8 +148,6 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, NULL);
>  	i2c_put_adapter(mux->parent);
> -	kfree(mux->adap);
> -	kfree(mux);
>  
>  	return 0;
>  }

Other than this it looks OK.

Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>

I don't know a thing about DT and ARM so I won't review the following
patches of this series. For this reason I will not pick this one in my
tree either, to avoid inter-tree dependencies.

-- 
Jean Delvare

  parent reply	other threads:[~2012-09-22 13:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21 15:32 [PATCH 0/3] ARM: I2C: Add device tree bindings to i2c-mux-gpio Maxime Ripard
     [not found] ` <1348241535-27754-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-09-21 15:32   ` [PATCH 1/3] i2c: i2c-mux-gpio: Use devm_kzalloc instead of kzalloc Maxime Ripard
     [not found]     ` <1348241535-27754-2-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-09-22 13:09       ` Jean Delvare [this message]
2012-09-22 13:22       ` Peter Korsgaard
2012-09-21 15:32   ` [PATCH 2/3] i2c: mux: Add dt support to i2c-mux-gpio driver Maxime Ripard
     [not found]     ` <1348241535-27754-3-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-09-21 16:37       ` Stephen Warren
2012-09-21 15:32   ` [PATCH 3/3] ARM: dts: cfa10049: Add the i2c muxer buses to the CFA-10049 Maxime Ripard
  -- strict thread matches above, loose matches on Subject: below --
2012-09-24  8:22 [PATCHv2 0/3] ARM: I2C: Add device tree bindings to i2c-mux-gpio Maxime Ripard
     [not found] ` <1348474926-12763-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-09-24  9:53   ` [PATCH 1/3] i2c: i2c-mux-gpio: Use devm_kzalloc instead of kzalloc Maxime Ripard
2012-09-27 15:13 [PATCHv3 0/3] ARM: I2C: Add device tree bindings to i2c-mux-gpio Maxime Ripard
     [not found] ` <1348758784-15245-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-09-27 15:13   ` [PATCH 1/3] i2c: i2c-mux-gpio: Use devm_kzalloc instead of kzalloc Maxime Ripard
     [not found]     ` <1348758784-15245-2-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2012-10-06 13:10       ` Jean Delvare

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=20120922150905.643f7604@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=brian-ZKiFAVwZFM2FeswfMrDH8w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org \
    --cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@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