Commit 7e97b581 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Bryan Wu

leds: Convert S3C24XX LED driver to devm_kzalloc()

Use the device managed resource API for simplifying
the error/driver remove paths.

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: default avatarSylwester Nawrocki <sylvester.nawrocki@gmail.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@canonical.com>
parent 317dfb14
...@@ -63,7 +63,6 @@ static int s3c24xx_led_remove(struct platform_device *dev) ...@@ -63,7 +63,6 @@ static int s3c24xx_led_remove(struct platform_device *dev)
struct s3c24xx_gpio_led *led = pdev_to_gpio(dev); struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
led_classdev_unregister(&led->cdev); led_classdev_unregister(&led->cdev);
kfree(led);
return 0; return 0;
} }
...@@ -74,7 +73,8 @@ static int s3c24xx_led_probe(struct platform_device *dev) ...@@ -74,7 +73,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
struct s3c24xx_gpio_led *led; struct s3c24xx_gpio_led *led;
int ret; int ret;
led = kzalloc(sizeof(struct s3c24xx_gpio_led), GFP_KERNEL); led = devm_kzalloc(&dev->dev, sizeof(struct s3c24xx_gpio_led),
GFP_KERNEL);
if (led == NULL) { if (led == NULL) {
dev_err(&dev->dev, "No memory for device\n"); dev_err(&dev->dev, "No memory for device\n");
return -ENOMEM; return -ENOMEM;
...@@ -103,10 +103,8 @@ static int s3c24xx_led_probe(struct platform_device *dev) ...@@ -103,10 +103,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
/* register our new led device */ /* register our new led device */
ret = led_classdev_register(&dev->dev, &led->cdev); ret = led_classdev_register(&dev->dev, &led->cdev);
if (ret < 0) { if (ret < 0)
dev_err(&dev->dev, "led_classdev_register failed\n"); dev_err(&dev->dev, "led_classdev_register failed\n");
kfree(led);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment