Skip to content

Commit

Permalink
pwm-backlight: Use devm_pwm_get() instead of pwm_get()
Browse files Browse the repository at this point in the history
Managed versions of the pwm_get() and pwm_put() functions were recently
added to the PWM framework. They can be used to simplify cleanup in the
error paths and the device removal callback.

Cc: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
  • Loading branch information
Sachin Kamat authored and Thierry Reding committed Oct 5, 2012
1 parent 6173f8f commit 60ce702
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->exit = data->exit;
pb->dev = &pdev->dev;

pb->pwm = pwm_get(&pdev->dev, NULL);
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm)) {
dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");

Expand Down Expand Up @@ -246,7 +246,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
if (IS_ERR(bl)) {
dev_err(&pdev->dev, "failed to register backlight\n");
ret = PTR_ERR(bl);
goto err_bl;
goto err_alloc;
}

bl->props.brightness = data->dft_brightness;
Expand All @@ -255,8 +255,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, bl);
return 0;

err_bl:
pwm_put(pb->pwm);
err_alloc:
if (data->exit)
data->exit(&pdev->dev);
Expand All @@ -271,7 +269,6 @@ static int pwm_backlight_remove(struct platform_device *pdev)
backlight_device_unregister(bl);
pwm_config(pb->pwm, 0, pb->period);
pwm_disable(pb->pwm);
pwm_put(pb->pwm);
if (pb->exit)
pb->exit(&pdev->dev);
return 0;
Expand Down

0 comments on commit 60ce702

Please sign in to comment.