Skip to content

Commit

Permalink
gpio: 74x164: Use devm_kzalloc
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Maxime Ripard authored and Linus Walleij committed Sep 7, 2012
1 parent ab3b878 commit 72eac30
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/gpio/gpio-74x164.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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);

Expand Down

0 comments on commit 72eac30

Please sign in to comment.