Skip to content

Commit

Permalink
leds: Use devm_kzalloc in leds-regulator.c file
Browse files Browse the repository at this point in the history
devm_kzalloc() makes cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Sachin Kamat authored and Bryan Wu committed Jul 23, 2012
1 parent 0b7da74 commit d415896
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/leds/leds-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
return PTR_ERR(vcc);
}

led = kzalloc(sizeof(*led), GFP_KERNEL);
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (led == NULL) {
ret = -ENOMEM;
goto err_vcc;
Expand All @@ -169,7 +169,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Invalid default brightness %d\n",
pdata->brightness);
ret = -EINVAL;
goto err_led;
goto err_vcc;
}
led->value = pdata->brightness;

Expand All @@ -190,7 +190,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)
ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0) {
cancel_work_sync(&led->work);
goto err_led;
goto err_vcc;
}

/* to expose the default value to userspace */
Expand All @@ -201,8 +201,6 @@ static int __devinit regulator_led_probe(struct platform_device *pdev)

return 0;

err_led:
kfree(led);
err_vcc:
regulator_put(vcc);
return ret;
Expand All @@ -216,7 +214,6 @@ static int __devexit regulator_led_remove(struct platform_device *pdev)
cancel_work_sync(&led->work);
regulator_led_disable(led);
regulator_put(led->vcc);
kfree(led);
return 0;
}

Expand Down

0 comments on commit d415896

Please sign in to comment.