aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-07-03 23:21:36 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:36 -0400
commit7f13bbf799f28d5c718a2f18c42f0c6ab56f501b (patch)
treeb34c59cc32eb3874ee5569994a3de29ec07a78cd /drivers/leds
parentd41589658ed1607303e702805c51030d6ecfc471 (diff)
leds: Use devm_kzalloc in leds-max8997.c file
devm_kzalloc() makes code cleanup simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-max8997.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c
index 86abfe24ad28..bf86d5483f43 100644
--- a/drivers/leds/leds-max8997.c
+++ b/drivers/leds/leds-max8997.c
@@ -276,11 +276,9 @@ static int __devinit max8997_led_probe(struct platform_device *pdev)
276 return -ENODEV; 276 return -ENODEV;
277 } 277 }
278 278
279 led = kzalloc(sizeof(*led), GFP_KERNEL); 279 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
280 if (led == NULL) { 280 if (led == NULL)
281 ret = -ENOMEM; 281 return -ENOMEM;
282 goto err_mem;
283 }
284 282
285 led->id = pdev->id; 283 led->id = pdev->id;
286 snprintf(name, sizeof(name), "max8997-led%d", pdev->id); 284 snprintf(name, sizeof(name), "max8997-led%d", pdev->id);
@@ -315,23 +313,17 @@ static int __devinit max8997_led_probe(struct platform_device *pdev)
315 313
316 ret = led_classdev_register(&pdev->dev, &led->cdev); 314 ret = led_classdev_register(&pdev->dev, &led->cdev);
317 if (ret < 0) 315 if (ret < 0)
318 goto err_led; 316 return ret;
319 317
320 ret = device_create_file(led->cdev.dev, &dev_attr_mode); 318 ret = device_create_file(led->cdev.dev, &dev_attr_mode);
321 if (ret != 0) { 319 if (ret != 0) {
322 dev_err(&pdev->dev, 320 dev_err(&pdev->dev,
323 "failed to create file: %d\n", ret); 321 "failed to create file: %d\n", ret);
324 goto err_file; 322 led_classdev_unregister(&led->cdev);
323 return ret;
325 } 324 }
326 325
327 return 0; 326 return 0;
328
329err_file:
330 led_classdev_unregister(&led->cdev);
331err_led:
332 kfree(led);
333err_mem:
334 return ret;
335} 327}
336 328
337static int __devexit max8997_led_remove(struct platform_device *pdev) 329static int __devexit max8997_led_remove(struct platform_device *pdev)
@@ -340,7 +332,6 @@ static int __devexit max8997_led_remove(struct platform_device *pdev)
340 332
341 device_remove_file(led->cdev.dev, &dev_attr_mode); 333 device_remove_file(led->cdev.dev, &dev_attr_mode);
342 led_classdev_unregister(&led->cdev); 334 led_classdev_unregister(&led->cdev);
343 kfree(led);
344 335
345 return 0; 336 return 0;
346} 337}