linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Evan McClain <aeroevan@gmail.com>
To: linux-leds@vger.kernel.org
Cc: Simon Que <sque@chromium.org>,
	Jacek Anaszewski <j.anaszewski@samsung.com>,
	Evan McClain <aeroevan@gmail.com>
Subject: [PATCH 3/3] leds: chromeos: Use devm_led_classdev_register.
Date: Mon, 22 Feb 2016 10:01:00 -0500	[thread overview]
Message-ID: <1456153260-3022-3-git-send-email-aeroevan@gmail.com> (raw)
In-Reply-To: <1456153260-3022-1-git-send-email-aeroevan@gmail.com>

Also use managed devm_kzalloc.

Signed-off-by: Evan McClain <aeroevan@gmail.com>
---
 drivers/leds/leds-chromeos-keyboard.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/leds-chromeos-keyboard.c b/drivers/leds/leds-chromeos-keyboard.c
index 6a6ff75..4e56ede 100644
--- a/drivers/leds/leds-chromeos-keyboard.c
+++ b/drivers/leds/leds-chromeos-keyboard.c
@@ -69,7 +69,7 @@ static int keyboard_led_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	cdev = kzalloc(sizeof(struct led_classdev), GFP_KERNEL);
+	cdev = devm_kzalloc(&pdev->dev, sizeof(struct led_classdev), GFP_KERNEL);
 	if (!cdev)
 		return -ENOMEM;
 	cdev->name = "chromeos::kbd_backlight";
@@ -78,15 +78,12 @@ static int keyboard_led_probe(struct platform_device *pdev)
 	cdev->brightness = cdev->max_brightness;
 	cdev->flags |= LED_CORE_SUSPENDRESUME;
 
-	ret = led_classdev_register(&pdev->dev, cdev);
+	ret = devm_led_classdev_register(&pdev->dev, cdev);
 	if (ret)
-		goto err;
+		return ret;
 
 	platform_set_drvdata(pdev, cdev);
 	return 0;
-err:
-	kfree(cdev);
-	return ret;
 }
 
 static int keyboard_led_remove(struct platform_device *pdev)
@@ -94,7 +91,6 @@ static int keyboard_led_remove(struct platform_device *pdev)
 	struct led_classdev *cdev = platform_get_drvdata(pdev);
 
 	platform_set_drvdata(pdev, NULL);
-	kfree(cdev);
 	return 0;
 }
 
-- 
2.5.0

  parent reply	other threads:[~2016-02-22 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 15:00 [PATCH 1/3] leds: Add Chrome OS keyboard LEDs driver Evan McClain
2016-02-22 15:00 ` [PATCH 2/3] leds: leds-chromeos-keyboard: Add ACPI _HID probing Evan McClain
2016-02-22 15:01 ` Evan McClain [this message]
2016-02-22 15:46 ` [PATCH 1/3] leds: Add Chrome OS keyboard LEDs driver Jacek Anaszewski
2016-02-22 16:02   ` Evan McClain
2016-02-23  8:21     ` Jacek Anaszewski

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=1456153260-3022-3-git-send-email-aeroevan@gmail.com \
    --to=aeroevan@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=sque@chromium.org \
    /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).