public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Richard Purdie <rpurdie@rpsys.net>,
	linux-kernel@vger.kernel.org, Johan Hovold <jhovold@gmail.com>
Subject: [PATCH] leds: lm3533: use devres to manage driver data
Date: Mon, 21 May 2012 17:52:39 +0200	[thread overview]
Message-ID: <1337615559-5868-1-git-send-email-jhovold@gmail.com> (raw)

Use devres to manage driver data.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/leds/leds-lm3533.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index 4ef496c..e968470 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -632,7 +632,7 @@ static int __devinit lm3533_led_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	led = kzalloc(sizeof(*led), GFP_KERNEL);
+	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
 	if (!led)
 		return -ENOMEM;
 
@@ -661,7 +661,7 @@ static int __devinit lm3533_led_probe(struct platform_device *pdev)
 	ret = led_classdev_register(pdev->dev.parent, &led->cdev);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id);
-		goto err_free;
+		return ret;
 	}
 
 	led->cb.dev = led->cdev.dev;
@@ -688,8 +688,6 @@ err_sysfs_remove:
 err_unregister:
 	led_classdev_unregister(&led->cdev);
 	flush_work_sync(&led->work);
-err_free:
-	kfree(led);
 
 	return ret;
 }
@@ -704,7 +702,6 @@ static int __devexit lm3533_led_remove(struct platform_device *pdev)
 	sysfs_remove_group(&led->cdev.dev->kobj, &lm3533_led_attribute_group);
 	led_classdev_unregister(&led->cdev);
 	flush_work_sync(&led->work);
-	kfree(led);
 
 	return 0;
 }
-- 
1.7.8.5


                 reply	other threads:[~2012-05-21 15:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1337615559-5868-1-git-send-email-jhovold@gmail.com \
    --to=jhovold@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /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