Commit 9ea6cdac authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Bryan Wu

leds: leds-pwm: Convert to use devm_get_pwm

Update the driver to use the new API for requesting pwm so we can take
advantage of the pwm_lookup table to find the correct pwm to be used for the
LED functionality.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
parent 8614fb46
...@@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev) ...@@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev)
cur_led = &pdata->leds[i]; cur_led = &pdata->leds[i];
led_dat = &leds_data[i]; led_dat = &leds_data[i];
led_dat->pwm = pwm_request(cur_led->pwm_id, led_dat->pwm = devm_pwm_get(&pdev->dev, cur_led->name);
cur_led->name);
if (IS_ERR(led_dat->pwm)) { if (IS_ERR(led_dat->pwm)) {
ret = PTR_ERR(led_dat->pwm); ret = PTR_ERR(led_dat->pwm);
dev_err(&pdev->dev, "unable to request PWM %d\n", dev_err(&pdev->dev, "unable to request PWM for %s\n",
cur_led->pwm_id); cur_led->name);
goto err; goto err;
} }
...@@ -86,10 +85,8 @@ static int led_pwm_probe(struct platform_device *pdev) ...@@ -86,10 +85,8 @@ static int led_pwm_probe(struct platform_device *pdev)
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
ret = led_classdev_register(&pdev->dev, &led_dat->cdev); ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
if (ret < 0) { if (ret < 0)
pwm_free(led_dat->pwm);
goto err; goto err;
}
} }
platform_set_drvdata(pdev, leds_data); platform_set_drvdata(pdev, leds_data);
...@@ -98,10 +95,8 @@ static int led_pwm_probe(struct platform_device *pdev) ...@@ -98,10 +95,8 @@ static int led_pwm_probe(struct platform_device *pdev)
err: err:
if (i > 0) { if (i > 0) {
for (i = i - 1; i >= 0; i--) { for (i = i - 1; i >= 0; i--)
led_classdev_unregister(&leds_data[i].cdev); led_classdev_unregister(&leds_data[i].cdev);
pwm_free(leds_data[i].pwm);
}
} }
return ret; return ret;
...@@ -115,10 +110,8 @@ static int led_pwm_remove(struct platform_device *pdev) ...@@ -115,10 +110,8 @@ static int led_pwm_remove(struct platform_device *pdev)
leds_data = platform_get_drvdata(pdev); leds_data = platform_get_drvdata(pdev);
for (i = 0; i < pdata->num_leds; i++) { for (i = 0; i < pdata->num_leds; i++)
led_classdev_unregister(&leds_data[i].cdev); led_classdev_unregister(&leds_data[i].cdev);
pwm_free(leds_data[i].pwm);
}
return 0; return 0;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
struct led_pwm { struct led_pwm {
const char *name; const char *name;
const char *default_trigger; const char *default_trigger;
unsigned pwm_id; unsigned pwm_id __deprecated;
u8 active_low; u8 active_low;
unsigned max_brightness; unsigned max_brightness;
unsigned pwm_period_ns; unsigned pwm_period_ns;
......
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