linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: wm831x: Convert to use devm_kzalloc API
@ 2012-09-02  3:58 Axel Lin
  2012-09-02  3:58 ` [PATCH 2/2] gpio: wm8350: " Axel Lin
  2012-09-04  7:25 ` [PATCH 1/2] gpio: wm831x: " Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2012-09-02  3:58 UTC (permalink / raw)
  To: Grant Likely, Linus Walleij; +Cc: Mark Brown, linux-kernel

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/gpio/gpio-wm831x.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c
index e56a216..b6eda35 100644
--- a/drivers/gpio/gpio-wm831x.c
+++ b/drivers/gpio/gpio-wm831x.c
@@ -250,7 +250,8 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
 	struct wm831x_gpio *wm831x_gpio;
 	int ret;
 
-	wm831x_gpio = kzalloc(sizeof(*wm831x_gpio), GFP_KERNEL);
+	wm831x_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm831x_gpio),
+				   GFP_KERNEL);
 	if (wm831x_gpio == NULL)
 		return -ENOMEM;
 
@@ -265,30 +266,20 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
 
 	ret = gpiochip_add(&wm831x_gpio->gpio_chip);
 	if (ret < 0) {
-		dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
-			ret);
-		goto err;
+		dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, wm831x_gpio);
 
 	return ret;
-
-err:
-	kfree(wm831x_gpio);
-	return ret;
 }
 
 static int __devexit wm831x_gpio_remove(struct platform_device *pdev)
 {
 	struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev);
-	int ret;
-
-	ret = gpiochip_remove(&wm831x_gpio->gpio_chip);
-	if (ret == 0)
-		kfree(wm831x_gpio);
 
-	return ret;
+	return  gpiochip_remove(&wm831x_gpio->gpio_chip);
 }
 
 static struct platform_driver wm831x_gpio_driver = {
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] gpio: wm8350: Convert to use devm_kzalloc API
  2012-09-02  3:58 [PATCH 1/2] gpio: wm831x: Convert to use devm_kzalloc API Axel Lin
@ 2012-09-02  3:58 ` Axel Lin
  2012-09-04  7:26   ` Linus Walleij
  2012-09-04  7:25 ` [PATCH 1/2] gpio: wm831x: " Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2012-09-02  3:58 UTC (permalink / raw)
  To: Grant Likely; +Cc: Linus Walleij, Mark Brown, linux-kernel

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/gpio/gpio-wm8350.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpio-wm8350.c b/drivers/gpio/gpio-wm8350.c
index a06af51..fb42938 100644
--- a/drivers/gpio/gpio-wm8350.c
+++ b/drivers/gpio/gpio-wm8350.c
@@ -116,7 +116,8 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev)
 	struct wm8350_gpio_data *wm8350_gpio;
 	int ret;
 
-	wm8350_gpio = kzalloc(sizeof(*wm8350_gpio), GFP_KERNEL);
+	wm8350_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm8350_gpio),
+				   GFP_KERNEL);
 	if (wm8350_gpio == NULL)
 		return -ENOMEM;
 
@@ -131,30 +132,20 @@ static int __devinit wm8350_gpio_probe(struct platform_device *pdev)
 
 	ret = gpiochip_add(&wm8350_gpio->gpio_chip);
 	if (ret < 0) {
-		dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
-			ret);
-		goto err;
+		dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, wm8350_gpio);
 
 	return ret;
-
-err:
-	kfree(wm8350_gpio);
-	return ret;
 }
 
 static int __devexit wm8350_gpio_remove(struct platform_device *pdev)
 {
 	struct wm8350_gpio_data *wm8350_gpio = platform_get_drvdata(pdev);
-	int ret;
-
-	ret = gpiochip_remove(&wm8350_gpio->gpio_chip);
-	if (ret == 0)
-		kfree(wm8350_gpio);
 
-	return ret;
+	return gpiochip_remove(&wm8350_gpio->gpio_chip);
 }
 
 static struct platform_driver wm8350_gpio_driver = {
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] gpio: wm831x: Convert to use devm_kzalloc API
  2012-09-02  3:58 [PATCH 1/2] gpio: wm831x: Convert to use devm_kzalloc API Axel Lin
  2012-09-02  3:58 ` [PATCH 2/2] gpio: wm8350: " Axel Lin
@ 2012-09-04  7:25 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2012-09-04  7:25 UTC (permalink / raw)
  To: Axel Lin; +Cc: Grant Likely, Mark Brown, linux-kernel

On Sun, Sep 2, 2012 at 5:58 AM, Axel Lin <axel.lin@gmail.com> wrote:

> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks!
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] gpio: wm8350: Convert to use devm_kzalloc API
  2012-09-02  3:58 ` [PATCH 2/2] gpio: wm8350: " Axel Lin
@ 2012-09-04  7:26   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2012-09-04  7:26 UTC (permalink / raw)
  To: Axel Lin; +Cc: Grant Likely, Mark Brown, linux-kernel

On Sun, Sep 2, 2012 at 5:58 AM, Axel Lin <axel.lin@gmail.com> wrote:

> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks!
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-04  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-02  3:58 [PATCH 1/2] gpio: wm831x: Convert to use devm_kzalloc API Axel Lin
2012-09-02  3:58 ` [PATCH 2/2] gpio: wm8350: " Axel Lin
2012-09-04  7:26   ` Linus Walleij
2012-09-04  7:25 ` [PATCH 1/2] gpio: wm831x: " Linus Walleij

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).