diff mbox

[2/8] gpio: 74x164: Use devm_kzalloc

Message ID 1346834457-6257-2-git-send-email-maxime.ripard@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maxime Ripard Sept. 5, 2012, 8:40 a.m. UTC
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/gpio/gpio-74x164.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Florian Fainelli Sept. 5, 2012, 8:46 a.m. UTC | #1
On Wednesday 05 September 2012 10:40:51 Maxime Ripard wrote:
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Acked-by: Florian Fainelli <florian@openwrt.org>

> ---
>  drivers/gpio/gpio-74x164.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
> index 2975036..604b998 100644
> --- a/drivers/gpio/gpio-74x164.c
> +++ b/drivers/gpio/gpio-74x164.c
> @@ -90,7 +90,7 @@ static int __devinit gen_74x164_probe(struct spi_device 
*spi)
>  	if (ret < 0)
>  		return ret;
>  
> -	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
> +	chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL);
>  	if (!chip)
>  		return -ENOMEM;
>  
> @@ -125,7 +125,6 @@ static int __devinit gen_74x164_probe(struct spi_device 
*spi)
>  exit_destroy:
>  	dev_set_drvdata(&spi->dev, NULL);
>  	mutex_destroy(&chip->lock);
> -	kfree(chip);
>  	return ret;
>  }
>  
> @@ -141,10 +140,9 @@ static int __devexit gen_74x164_remove(struct 
spi_device *spi)
>  	dev_set_drvdata(&spi->dev, NULL);
>  
>  	ret = gpiochip_remove(&chip->gpio_chip);
> -	if (!ret) {
> +	if (!ret)
>  		mutex_destroy(&chip->lock);
> -		kfree(chip);
> -	} else
> +	else
>  		dev_err(&spi->dev, "Failed to remove the GPIO controller: %d\n",
>  				ret);
>  
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thomas Petazzoni Sept. 5, 2012, 9:16 a.m. UTC | #2
Le Wed,  5 Sep 2012 10:40:51 +0200,
Maxime Ripard <maxime.ripard@free-electrons.com> a écrit :

> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Linus Walleij Sept. 6, 2012, 7:22 a.m. UTC | #3
On Wed, Sep 5, 2012 at 10:40 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:

> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  drivers/gpio/gpio-74x164.c |    8 +++-----

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Sept. 7, 2012, 9:02 p.m. UTC | #4
On Wed, Sep 5, 2012 at 10:40 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:

> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied.

Thanks,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index 2975036..604b998 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -90,7 +90,7 @@  static int __devinit gen_74x164_probe(struct spi_device *spi)
 	if (ret < 0)
 		return ret;
 
-	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+	chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
 
@@ -125,7 +125,6 @@  static int __devinit gen_74x164_probe(struct spi_device *spi)
 exit_destroy:
 	dev_set_drvdata(&spi->dev, NULL);
 	mutex_destroy(&chip->lock);
-	kfree(chip);
 	return ret;
 }
 
@@ -141,10 +140,9 @@  static int __devexit gen_74x164_remove(struct spi_device *spi)
 	dev_set_drvdata(&spi->dev, NULL);
 
 	ret = gpiochip_remove(&chip->gpio_chip);
-	if (!ret) {
+	if (!ret)
 		mutex_destroy(&chip->lock);
-		kfree(chip);
-	} else
+	else
 		dev_err(&spi->dev, "Failed to remove the GPIO controller: %d\n",
 				ret);