Skip to content

Commit

Permalink
leds: Convert S3C24XX LED driver to devm_kzalloc()
Browse files Browse the repository at this point in the history
Use the device managed resource API for simplifying
the error/driver remove paths.

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
snawrocki authored and Bryan Wu committed Jul 23, 2012
1 parent 317dfb1 commit 7e97b58
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/leds/leds-s3c24xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static int s3c24xx_led_remove(struct platform_device *dev)
struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);

led_classdev_unregister(&led->cdev);
kfree(led);

return 0;
}
Expand All @@ -74,7 +73,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
struct s3c24xx_gpio_led *led;
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) {
dev_err(&dev->dev, "No memory for device\n");
return -ENOMEM;
Expand Down Expand Up @@ -103,10 +103,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
/* register our new led device */

ret = led_classdev_register(&dev->dev, &led->cdev);
if (ret < 0) {
if (ret < 0)
dev_err(&dev->dev, "led_classdev_register failed\n");
kfree(led);
}

return ret;
}
Expand Down

0 comments on commit 7e97b58

Please sign in to comment.