Commit 482467ad authored by Jingoo Han's avatar Jingoo Han Committed by Thierry Reding

pwm: ab8500: use devm_kzalloc()

Use devm_kzalloc() to make cleanup paths more simple.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@avionic-design.de>
parent c791126b
...@@ -99,7 +99,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev) ...@@ -99,7 +99,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
* Nothing to be done in probe, this is required to get the * Nothing to be done in probe, this is required to get the
* device which is required for ab8500 read and write * device which is required for ab8500 read and write
*/ */
ab8500 = kzalloc(sizeof(*ab8500), GFP_KERNEL); ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL);
if (ab8500 == NULL) { if (ab8500 == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n"); dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -111,10 +111,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev) ...@@ -111,10 +111,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
ab8500->chip.npwm = 1; ab8500->chip.npwm = 1;
err = pwmchip_add(&ab8500->chip); err = pwmchip_add(&ab8500->chip);
if (err < 0) { if (err < 0)
kfree(ab8500);
return err; return err;
}
dev_dbg(&pdev->dev, "pwm probe successful\n"); dev_dbg(&pdev->dev, "pwm probe successful\n");
platform_set_drvdata(pdev, ab8500); platform_set_drvdata(pdev, ab8500);
...@@ -132,7 +130,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev) ...@@ -132,7 +130,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev)
return err; return err;
dev_dbg(&pdev->dev, "pwm driver removed\n"); dev_dbg(&pdev->dev, "pwm driver removed\n");
kfree(ab8500);
return 0; return 0;
} }
......
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