aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorSylwester Nawrocki <sylvester.nawrocki@gmail.com>2012-06-30 08:30:25 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:36 -0400
commit7e97b58133b7cddf3be80660300bb2c77c514c6f (patch)
treec27aa227a5228dac038286ff82c0f767939d0653 /drivers/leds
parent317dfb148d606a92e7d2748ab77f3d8f9749cc8a (diff)
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: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-s3c24xx.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index e6ee1054826..b816ccb9adf 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)
63 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev); 63 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
64 64
65 led_classdev_unregister(&led->cdev); 65 led_classdev_unregister(&led->cdev);
66 kfree(led);
67 66
68 return 0; 67 return 0;
69} 68}
@@ -74,7 +73,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
74 struct s3c24xx_gpio_led *led; 73 struct s3c24xx_gpio_led *led;
75 int ret; 74 int ret;
76 75
77 led = kzalloc(sizeof(struct s3c24xx_gpio_led), GFP_KERNEL); 76 led = devm_kzalloc(&dev->dev, sizeof(struct s3c24xx_gpio_led),
77 GFP_KERNEL);
78 if (led == NULL) { 78 if (led == NULL) {
79 dev_err(&dev->dev, "No memory for device\n"); 79 dev_err(&dev->dev, "No memory for device\n");
80 return -ENOMEM; 80 return -ENOMEM;
@@ -103,10 +103,8 @@ static int s3c24xx_led_probe(struct platform_device *dev)
103 /* register our new led device */ 103 /* register our new led device */
104 104
105 ret = led_classdev_register(&dev->dev, &led->cdev); 105 ret = led_classdev_register(&dev->dev, &led->cdev);
106 if (ret < 0) { 106 if (ret < 0)
107 dev_err(&dev->dev, "led_classdev_register failed\n"); 107 dev_err(&dev->dev, "led_classdev_register failed\n");
108 kfree(led);
109 }
110 108
111 return ret; 109 return ret;
112} 110}