Skip to content

Commit

Permalink
leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup …
Browse files Browse the repository at this point in the history
…error exit path

Cc: Eric Miao <eric.miao@canonical.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Bryan Wu committed Jul 23, 2012
1 parent 9813d74 commit bad1c89
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions drivers/leds/leds-da903x.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static int __devinit da903x_led_probe(struct platform_device *pdev)
return -EINVAL;
}

led = kzalloc(sizeof(struct da903x_led), GFP_KERNEL);
led = devm_kzalloc(&pdev->dev, sizeof(struct da903x_led), GFP_KERNEL);
if (led == NULL) {
dev_err(&pdev->dev, "failed to alloc memory for LED%d\n", id);
return -ENOMEM;
Expand All @@ -129,23 +129,18 @@ static int __devinit da903x_led_probe(struct platform_device *pdev)
ret = led_classdev_register(led->master, &led->cdev);
if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", id);
goto err;
return ret;
}

platform_set_drvdata(pdev, led);
return 0;

err:
kfree(led);
return ret;
}

static int __devexit da903x_led_remove(struct platform_device *pdev)
{
struct da903x_led *led = platform_get_drvdata(pdev);

led_classdev_unregister(&led->cdev);
kfree(led);
return 0;
}

Expand Down

0 comments on commit bad1c89

Please sign in to comment.