Commit 60a0aadb authored by Bryan Wu's avatar Bryan Wu

leds: convert HTC ASIC3 LED driver to devm_kzalloc() and cleanup error exit path

Cc: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@canonical.com>
parent 8095c385
...@@ -99,12 +99,13 @@ static int __devinit asic3_led_probe(struct platform_device *pdev) ...@@ -99,12 +99,13 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)
ret = mfd_cell_enable(pdev); ret = mfd_cell_enable(pdev);
if (ret < 0) 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) { if (!led->cdev) {
ret = -ENOMEM; ret = -ENOMEM;
goto ret1; goto out;
} }
led->cdev->name = led->name; led->cdev->name = led->name;
...@@ -115,15 +116,12 @@ static int __devinit asic3_led_probe(struct platform_device *pdev) ...@@ -115,15 +116,12 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)
ret = led_classdev_register(&pdev->dev, led->cdev); ret = led_classdev_register(&pdev->dev, led->cdev);
if (ret < 0) if (ret < 0)
goto ret2; goto out;
return 0; return 0;
ret2: out:
kfree(led->cdev);
ret1:
(void) mfd_cell_disable(pdev); (void) mfd_cell_disable(pdev);
ret0:
return ret; return ret;
} }
...@@ -133,8 +131,6 @@ static int __devexit asic3_led_remove(struct platform_device *pdev) ...@@ -133,8 +131,6 @@ static int __devexit asic3_led_remove(struct platform_device *pdev)
led_classdev_unregister(led->cdev); led_classdev_unregister(led->cdev);
kfree(led->cdev);
return mfd_cell_disable(pdev); return mfd_cell_disable(pdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment