[PATCH v3 1/4] leds: leds-pwm: Convert to use devm_get_pwm

Thierry Reding thierry.reding at avionic-design.de
Tue Dec 11 18:03:07 EST 2012


On Mon, Dec 10, 2012 at 11:00:34AM +0100, Peter Ujfalusi wrote:
> 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.
> If the devm_get_pwm fails we fall back to legacy mode to try to get the pwm.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
> ---
>  drivers/leds/leds-pwm.c  | 19 ++++++-------------
>  include/linux/leds_pwm.h |  2 +-
>  2 files changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index 2157524..351257c 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev)
>  		cur_led = &pdata->leds[i];
>  		led_dat = &leds_data[i];
>  
> -		led_dat->pwm = pwm_request(cur_led->pwm_id,
> -				cur_led->name);
> +		led_dat->pwm = devm_pwm_get(&pdev->dev, cur_led->name);
>  		if (IS_ERR(led_dat->pwm)) {
>  			ret = PTR_ERR(led_dat->pwm);
> -			dev_err(&pdev->dev, "unable to request PWM %d\n",
> -					cur_led->pwm_id);
> +			dev_err(&pdev->dev, "unable to request PWM for %s\n",
> +				cur_led->name);
>  			goto err;
>  		}

The commit message says that legacy mode is used as fallback if
devm_get_pwm() (that should really be devm_pwm_get() btw) fails but I
don't see where pwm_request() is called.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20121211/0dc3452c/attachment.sig>


More information about the devicetree-discuss mailing list