From: Sylwester Nawrocki Date: Sat, 30 Jun 2012 12:30:25 +0000 (+0800) Subject: leds: Convert S3C24XX LED driver to devm_kzalloc() X-Git-Tag: MMI-PSA29.97-13-9~16253^2~34 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e97b58133b7cddf3be80660300bb2c77c514c6f;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git leds: Convert S3C24XX LED driver to devm_kzalloc() Use the device managed resource API for simplifying the error/driver remove paths. Cc: Ben Dooks Signed-off-by: Sylwester Nawrocki Signed-off-by: Bryan Wu --- diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c index e6ee10548265..b816ccb9adf4 100644 --- a/drivers/leds/leds-s3c24xx.c +++ b/drivers/leds/leds-s3c24xx.c @@ -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; } @@ -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; @@ -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; }