Skip to content

Commit

Permalink
leds: convert HTC ASIC3 LED driver to devm_kzalloc() and cleanup erro…
Browse files Browse the repository at this point in the history
…r exit path

Cc: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Bryan Wu committed Jul 23, 2012
1 parent 8095c38 commit 60a0aad
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions drivers/leds/leds-asic3.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)

ret = mfd_cell_enable(pdev);
if (ret < 0)
goto ret0;
return ret;

led->cdev = kzalloc(sizeof(struct led_classdev), GFP_KERNEL);
led->cdev = devm_kzalloc(&pdev->dev, sizeof(struct led_classdev),
GFP_KERNEL);
if (!led->cdev) {
ret = -ENOMEM;
goto ret1;
goto out;
}

led->cdev->name = led->name;
Expand All @@ -115,15 +116,12 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)

ret = led_classdev_register(&pdev->dev, led->cdev);
if (ret < 0)
goto ret2;
goto out;

return 0;

ret2:
kfree(led->cdev);
ret1:
out:
(void) mfd_cell_disable(pdev);
ret0:
return ret;
}

Expand All @@ -133,8 +131,6 @@ static int __devexit asic3_led_remove(struct platform_device *pdev)

led_classdev_unregister(led->cdev);

kfree(led->cdev);

return mfd_cell_disable(pdev);
}

Expand Down

0 comments on commit 60a0aad

Please sign in to comment.