linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Varka Bhadram <varkabhadram@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: linus.walleij@linaro.org, gnurou@gmail.com,
	Varka Bhadram <varkab@cdac.in>
Subject: [PATCH gpio 1/4] drivers: gpio: use devm_kzalloc
Date: Tue, 31 Mar 2015 09:49:08 +0530	[thread overview]
Message-ID: <1427775551-6908-2-git-send-email-varkab@cdac.in> (raw)
In-Reply-To: <1427775551-6908-1-git-send-email-varkab@cdac.in>

We can use devres API for allocating memory. No need of using kfree.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/gpio/gpio-adp5588.c  |    3 +--
 drivers/gpio/gpio-mcp23s08.c |    7 ++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 3beed6e..0de8c70 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
 		return -EIO;
 	}
 
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL)
 		return -ENOMEM;
 
@@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client,
 err_irq:
 	adp5588_irq_teardown(dev);
 err:
-	kfree(dev);
 	return ret;
 }
 
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index eea5d7e..a17b81f 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi)
 	if (!chips)
 		return -ENODEV;
 
-	data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
-			GFP_KERNEL);
+	data = devm_kzalloc(&spi->dev,
+			    sizeof(*data) + chips * sizeof(struct mcp23s08),
+			    GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
+
 	spi_set_drvdata(spi, data);
 
 	spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0);
@@ -989,7 +991,6 @@ fail:
 			continue;
 		gpiochip_remove(&data->mcp[addr]->chip);
 	}
-	kfree(data);
 	return status;
 }
 
-- 
1.7.9.5


  reply	other threads:[~2015-03-31  4:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31  4:19 [PATCH gpio 0/4] cleanup for gpio drivers Varka Bhadram
2015-03-31  4:19 ` Varka Bhadram [this message]
2015-04-07 14:19   ` [PATCH gpio 1/4] drivers: gpio: use devm_kzalloc Linus Walleij
2015-04-07 15:40     ` Johan Hovold
2015-04-07 15:37   ` Johan Hovold
2015-03-31  4:19 ` [PATCH gpio 2/4] gpio-max7300: remove 'ret' variable Varka Bhadram
2015-04-07 14:20   ` Linus Walleij
2015-03-31  4:19 ` [PATCH gpio 3/4] gpio-arizona: drop owner assignment from platform_drivers Varka Bhadram
2015-04-07 14:21   ` Linus Walleij
2015-03-31  4:19 ` [PATCH gpio 4/4] drivers: gpio: use (!foo) instead of (foo == NULL) Varka Bhadram
2015-04-07 14:22   ` Linus Walleij
2015-04-08  1:50     ` Alexandre Courbot
2015-04-08 14:56       ` Linus Walleij

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=1427775551-6908-2-git-send-email-varkab@cdac.in \
    --to=varkabhadram@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=varkab@cdac.in \
    /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).